当当网商品详情API接口(当当商品详情接口,当当商品评论接口,当当商品问答接口,当当抢购价接口,当当商品列表接口)代码对接教程
生活随笔
收集整理的這篇文章主要介紹了
当当网商品详情API接口(当当商品详情接口,当当商品评论接口,当当商品问答接口,当当抢购价接口,当当商品列表接口)代码对接教程
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
當(dāng)當(dāng)網(wǎng)商品詳情API接口(當(dāng)當(dāng)商品詳情接口,當(dāng)當(dāng)商品評論接口,當(dāng)當(dāng)商品問答接口,當(dāng)當(dāng)搶購價接口,當(dāng)當(dāng)商品列表接口,關(guān)鍵詞搜索當(dāng)當(dāng)網(wǎng)商品接口)代碼對接教程如下
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=25122027
參數(shù)說明:num_iid:當(dāng)當(dāng)商品ID
備注:可以支持高并發(fā)調(diào)用接口?
3.請求示例(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/dangdang/item_get/?key=<您自己的apiKey>&secret=<您自己的apiSecret>&num_iid=25122027";JSONObject json = getRequestFromUrl(url);System.out.println(json.toString());}}?4.響應(yīng)示例
{"item": {"num_iid": "25122027","title": "朗讀者(1-3輯)(榮獲2017年度大眾喜愛的50種圖書)","desc_short": "","price": "156.00","total_price": 0,"suggestive_price": 0,"orginal_price": "156.00","nick": "","num": "","min_num": 0,"detail_url": "http://product.dangdang.com/25122027.html","pic_url": "//img3m7.ddimg.cn/84/26/25122027-1_u_8.jpg","brand": "","brandId": "","rootCatId": "","cid": "","crumbs": [],"created_time": "","modified_time": "","delist_time": "","desc": "","desc_img": [],"item_imgs": [{"url": "//img3m7.ddimg.cn/84/26/25122027-1_u_8.jpg"},{"url": "//img3m7.ddimg.cn/84/26/25122027-2_u_3.jpg"},{"url": "//img3m7.ddimg.cn/84/26/25122027-3_u_1.jpg"},{"url": "//img3m7.ddimg.cn/84/26/25122027-4_u_1.jpg"},{"url": "//img3m7.ddimg.cn/84/26/25122027-5_u_1.jpg"},{"url": "//img3m7.ddimg.cn/84/26/25122027-6_u_1.jpg"}],"item_weight": "","item_size": "","location": "","post_fee": "","express_fee": "","ems_fee": "","shipping_to": "","has_discount": "","video": [],"is_virtual": "","sample_id": "","is_promotion": "","props_name": "","prop_imgs": {"prop_img": []},"property_alias": "","props": [{"name": "開 本","value": "32開"},{"name": "紙 張","value": "膠版紙"},{"name": "包 裝","value": "平裝-膠訂"},{"name": "是否套裝","value": "是"},{"name": "國際標(biāo)準(zhǔn)書號ISBN","value": "25122027"}],"total_sold": "","skus": {"sku": []},"seller_id": "","sales": 0,"shop_id": "","props_list": [],"seller_info": {"nick": "","shop_name": "","city": "","level": "","rate": "","totle_pf": "","desc_pf": "","server_pf": "","send_pf": "","shop_type": "","user_num_id": "","shopid": "","shopname": "","zhuy": "http://shop.dangdang.com/","tel": "","menu": []},"tmall": "","error": "","warning": "","url_log": "","sold": "88930","stuff_status": "","props_img": [],"shopinfo": {"shop_name": ""},"promo_type": "","shop_item": [],"relate_items": [],"format_check": "ok"},"error": "","secache": "665a65ebbf05689bd424affec75b2af6","secache_time": 1661739308,"secache_date": "2022-08-29 10:15:08","translate_status": "","translate_time": 0,"language": {"default_lang": "cn","current_lang": "cn"},"reason": "","error_code": "0000","cache": 0,"api_info": "today:21 max:10100 all[77=21+29+27];expires:2030-12-31","execution_time": "0.325","server_time": "Beijing/2022-08-29 10:15:08","client_ip": "106.6.36.86","call_args": {"num_iid": "25122027"},"api_type": "dangdang","translate_language": "zh-CN","translate_engine": "baidu","server_memory": "0.76MB","request_id": "gw-4.630c212c5c5cf","last_id": "1181945063" }總結(jié)
以上是生活随笔為你收集整理的当当网商品详情API接口(当当商品详情接口,当当商品评论接口,当当商品问答接口,当当抢购价接口,当当商品列表接口)代码对接教程的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Java基础学习Day09--字符串
- 下一篇: Lisp:AutoLisp入门、操作编程