Alimama commission conversion API interface (Alimama rebate interface, Taobao customer commission interface, Taobao link conversion interface, Taobao commission conversion interface) code docking tutorial is as follows:
1. Public parameters
name | type | must | describe |
---|---|---|---|
key | String | yes | Call key (must be spliced in the URL in GET mode, click to get the request key and secret ) |
secret | String | yes | call key |
api_name | String | yes | API interface name (included in the request address) [item_search, item_get, item_search_shop, etc.] |
cache | String | no | [yes, no] The default is yes, the cached data will be called, and the speed is relatively fast |
result_type | String | no | [json,jsonu,xml,serialize,var_export] returns the data format, the default is json, and the content output by jsonu can be read directly in Chinese |
lang | String | no | [cn,en,ru] translation language, default cn Simplified Chinese |
version | String | no | API version |
2. Request parameters (interface code tutorial wx19970108018)
Request parameter: id=40948381564&pid=mm_1409800143_2028300495_110837200055&tbname=oneboundcn&hasiteminfo=&extsearch=&tpwd=&shorturl=
Parameter description: *id: product ID of Taobao Tmall
*pid: pid
*tbname: nickname of Taobao
hasiteminfo: Whether to output product information, it is not recommended to enable it during Double Eleven, 1=enable, 0=disable
extsearch: not found by the official Whether to go to the third-party platform to check when couponing, 1 is to enable
tpwd: whether to generate Taobao password, 1 is to generate, not to generate
shorturl: whether to need a short link, 1 to generate, not to generate
3. Response parameters
4. Request example (CURL, PHP, PHPsdk, Java, C#, Python...)
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.net.URL;
import java.nio.charset.Charset;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.PrintWriter;
import java.net.URLConnection;
public class Example {
private static String readAll(Reader rd) throws IOException {
StringBuilder sb = new StringBuilder();
int cp;
while ((cp = rd.read()) != -1) {
sb.append((char) cp);
}
return sb.toString();
}
public static JSONObject postRequestFromUrl(String url, String body) throws IOException, JSONException {
URL realUrl = new URL(url);
URLConnection conn = realUrl.openConnection();
conn.setDoOutput(true);
conn.setDoInput(true);
PrintWriter out = new PrintWriter(conn.getOutputStream());
out.print(body);
out.flush();
InputStream instream = conn.getInputStream();
try {
BufferedReader rd = new BufferedReader(new InputStreamReader(instream, Charset.forName("UTF-8")));
String jsonText = readAll(rd);
JSONObject json = new JSONObject(jsonText);
return json;
} finally {
instream.close();
}
}
public static JSONObject getRequestFromUrl(String url) throws IOException, JSONException {
URL realUrl = new URL(url);
URLConnection conn = realUrl.openConnection();
InputStream instream = conn.getInputStream();
try {
BufferedReader rd = new BufferedReader(new InputStreamReader(instream, Charset.forName("UTF-8")));
String jsonText = readAll(rd);
JSONObject json = new JSONObject(jsonText);
return json;
} finally {
instream.close();
}
}
public static void main(String[] args) throws IOException, JSONException {
// 请求示例 url 默认请求参数已经URL编码处理
String url = "https://wx19970108018/alimama/item_id/?key=<您自己的apiKey>&secret=<您自己的apiSecret>&id=40948381564&pid=mm_1409800143_2028300495_110837200055&tbname=oneboundcn&hasiteminfo=&extsearch=&tpwd=&shorturl=";
JSONObject json = getRequestFromUrl(url);
System.out.println(json.toString());
}
}