Welcome to the Kelkoo Group Customer Service

Signing URL – Java

This example illustrates how to sign request URL’s using .NET C#. In Java, you will need to download the following JAR to be able to execute the function.

Variables

Name Type Summary
urlDomain string (required) URL of the service (ex: http://uk.shoppingapis.kelkoo.com)
urlPath string (required) Path and query for the service (ex: /V3/productSearch?query=ipod)
partner string (required) Affiliate Id
key string (required) Affiliate secret key

Please note that your query must be encoded if you use characters with accents. In Java you can use URLEncoder in java.net.URLEncoder.

Sample Class

 

public static String signUrl(String urlDomain, String urlPath, String partner, String key) throws Exception {
String URL_sig = "hash";
 String URL_ts = "timestamp";
 String URL_partner = "aid";
 String URLreturn = null;
long time = System.currentTimeMillis() / 1000
// format URL
 String URLtmp = urlPath + "&" + URL_partner + "=" + partner + "&" + URL_ts + "=" + time;
String tokken = null;
 MessageDigest md = MessageDigest.getInstance("MD5");
 try {
 MessageDigest tc1 = (MessageDigest) md.clone();
 String s = URLtmp + key;
byte[] toChapter1Digest = tc1.digest(s.getBytes("UTF-8"));
byte[] b = Base64.encodeBase64(toChapter1Digest);
 tokken = new String(b, "UTF-8");
 tokken = tokken.replace('+', '.').replace('/', '_').replace('=', '-');
 } catch (CloneNotSupportedException cnse) {
 throw new DigestException("couldn't make digest of partial content");
 }
// format the concatained final URL
 URLreturn = urlDomain + URLtmp + "&" + URL_sig + "=" + tokken;
return URLreturn;
 }

 

Simply call the function to generate the appropriate URL:

 import UrlSigner;
String query = UrlSigner.signUrl("http://ru.shoppingapis.kelkoo.com",
 "/V3/productSearch?query="+URIUtil.encodeQuery("Мода")+"&sort=default_ranking&start=1&results=20&show_products=1&show_subcategories=1&show_refinements=1", "123","PartnerKey");