一、接口参数说明: 通过1688app中分享至PC端的短链接,通过调用item_password - 获得淘口令真实url接口,可以得到转换后的PC端商品链接及商品ID,再次调用商品详情接口即可拿到该淘口令接口要的商品详情数据。 点击获取测试key和secret 二、请求参数: 请求参数:word=https%3A%2F%2Fqr.1688.com%2Fshare.html%3Fsecret=FIH6kmCT&title=no 参数说明:word:淘口令代码 title:是否获取标题和图片 三、响应参数: 名称 类型 示例值 描述 item item[] 商品信息 num_iid String 553327559647 宝贝ID url String https://detail.1688.com/offer/553327559647.html 淘口令真实url word String https://qr.1688.com/share.html?secret=FIH6kmCT 淘口令内容 error String error taobao password 错误提示 四、请求示例:(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 {
String url = "https://注册获取完整请求链接/1688/item_password/?key=<您自己的apiKey>&secret=<您自己的apiSecret>&word=https%3A%2F%2Fqr.1688.com%2Fshare.html%3Fsecret=FIH6kmCT&title=no";
JSONObject json = getRequestFromUrl(url);
System.out.println(json.toString());
}
}
响应示例:
{
"item": {
"num_iid": "553327559647",
"url": "https://detail.1688.com/offer/553327559647.html",
"word": "https://qr.1688.com/share.html?secret=FIH6kmCT",
"error": ""
},
"error": "",
"reason": "",
"error_code": "0000",
"cache": 0,
"api_info": "today:9 max:10000",
"execution_time": 1.389,
"server_time": "Beijing/2021-03-09 17:05:36",
"client_ip": "106.6.35.144",
"call_args": [],
"api_type": "1688",
"translate_language": "zh-CN",
"translate_engine": "google_cn",
"server_memory": "3.47MB",
"request_id": "gw-3.60473a5ec66b1"
}
API 工具 API SDK调用示例 APISDK下载 API测试工具
如何开通API测试,点击立即开通
|