淘特商品详情API接口(商品销量接口,商品销量排序接口,商品价格接口,商品属性接口)
生活随笔
收集整理的這篇文章主要介紹了
淘特商品详情API接口(商品销量接口,商品销量排序接口,商品价格接口,商品属性接口)
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
淘特商品詳情API接口(商品銷量接口,商品銷量排序接口,商品價格接口,商品屬性接口)代碼對接如下:
1.公共參數(shù)
| key | String | 是 | 調(diào)用key(必須以GET方式拼接在URL中,點擊獲取請求key和secret) |
| secret | String | 是 | 調(diào)用密鑰 |
| api_name | String | 是 | API接口名稱(包括在請求地址中)[item_search,item_get,item_search_shop等] |
| cache | String | 否 | [yes,no]默認(rèn)yes,將調(diào)用緩存的數(shù)據(jù),速度比較快 |
| result_type | String | 否 | [json,jsonu,xml,serialize,var_export]返回數(shù)據(jù)格式,默認(rèn)為json,jsonu輸出的內(nèi)容中文可以直接閱讀 |
| lang | String | 否 | [cn,en,ru]翻譯語言,默認(rèn)cn簡體中文 |
| version | String | 否 | API版本 |
2.請求參數(shù)
請求參數(shù):num_iid=675537450197?
參數(shù)說明:num_iid:淘特商品ID
商品鏈接:詳情頁??
3.響應(yīng)參數(shù)(與淘特app詳情數(shù)據(jù)一致)
?
?
4.請求示例(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 默認(rèn)請求參數(shù)已經(jīng)URL編碼處理String url = "https://wx19970108018/taobao/item_search/?key=<您自己的apiKey>&secret=<您自己的apiSecret>&q=女裝&start_price=0&end_price=0&page=1&cat=0&discount_only=&sort=&page_size=&seller_info=&nick=&ppath=&imgid=&filter=";JSONObject json = getRequestFromUrl(url);System.out.println(json.toString());}}總結(jié)
以上是生活随笔為你收集整理的淘特商品详情API接口(商品销量接口,商品销量排序接口,商品价格接口,商品属性接口)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 华为T8950d和小米手机1对比
- 下一篇: 机器人点灯(light-bot)2.0通