关于大数据:阿里巴巴中国站获得店铺的所有商品-API-返回值说明1688-店铺所有商品接口1688API

24次阅读

共计 2125 个字符,预计需要花费 6 分钟才能阅读完成。

1688.item_search_shop – 取得店铺的所有商品 API 返回值阐明
1. 公共参数:

名称 类型 必须 形容
key String 是 调用 key(必须以 GET 形式拼接在 URL 中,复制 Taobaoapi2014)
secret String 是 调用密钥
api_name String 是 API 接口名称(包含在申请地址中)[item_search,item_get,item_search_shop 等]
cache String 否 [yes,no] 默认 yes,将调用缓存的数据,速度比拟快
result_type String 否 [json,jsonu,xml,serialize,var_export] 返回数据格式,默认为 json,jsonu 输入的内容中文能够间接浏览
lang String 否 [cn,en,ru] 翻译语言,默认 cn 简体中文
version String 否 API 版本
2. 申请形式:HTTP POST GET
3. 申请地址:http://o0b.cn/opandy
4. 申请示例:

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://api-vxx.Taobaoapi2014.cn/taobao/item_get/?key=< 您本人的 apiKey>&secret=< 您本人的 apiSecret>&num_iid=652874751412&is_promotion=1";
        JSONObject json = getRequestFromUrl(url);
        System.out.println(json.toString());
    }

}

正文完
 0