ToB企服应用市场:ToB评测及商务社交产业平台

标题: 淘宝详情API接口文档(java)get调用 [打印本页]

作者: 祗疼妳一个    时间: 2024-5-17 00:17
标题: 淘宝详情API接口文档(java)get调用
淘宝详情API接口是用于获取淘宝商品具体信息的接口,它允许开发者通过发送请求,获取商品的形貌、代价、评价等信息。下面是一个关于淘宝详情API接口的示例文档,包括接口地址、请求参数、响应参数等内容。
淘宝详情API接口文档
一、接口地址
  1. https://api-gw.onebound.cn/taobao/item_get
复制代码
二、请求参数
  1. 请求参数:num_iid=652874751412&is_promotion=1
  2. 参数说明:num_iid:淘宝商品ID
  3. is_promotion:是否获取取促销价
复制代码
三、请求示例
  1. import java.io.BufferedReader;
  2. import java.io.IOException;
  3. import java.io.InputStream;
  4. import java.io.InputStreamReader;
  5. import java.io.Reader;
  6. import java.net.URL;
  7. import java.nio.charset.Charset;
  8. import org.json.JSONException;
  9. import org.json.JSONObject;
  10. import java.io.PrintWriter;
  11. import java.net.URLConnection;
  12. public class Example {
  13.         private static String readAll(Reader rd) throws IOException {
  14.                 StringBuilder sb = new StringBuilder();
  15.                 int cp;
  16.                 while ((cp = rd.read()) != -1) {
  17.                         sb.append((char) cp);
  18.                 }
  19.                 return  sb.toString();
  20.         }
  21.         public static JSONObject postRequestFromUrl(String url, String body) throws IOException, JSONException {
  22.                 URL realUrl = new URL(url);
  23.                 URLConnection conn = realUrl.openConnection();
  24.                 conn.setDoOutput(true);
  25.                 conn.setDoInput(true);
  26.                 PrintWriter out = new PrintWriter(conn.getOutputStream());
  27.                 out.print(body);
  28.                 out.flush();
  29.                 InputStream instream = conn.getInputStream();
  30.                 try {
  31.                         BufferedReader rd = new BufferedReader(new InputStreamReader(instream, Charset.forName("UTF-8")));
  32.                         String jsonText = readAll(rd);
  33.                         JSONObject json = new JSONObject(jsonText);
  34.                         return json;
  35.                 } finally {
  36.                         instream.close();
  37.                 }
  38.         }
  39.         public static JSONObject getRequestFromUrl(String url) throws IOException, JSONException {
  40.                 URL realUrl = new URL(url);
  41.                 URLConnection conn = realUrl.openConnection();
  42.                 InputStream instream = conn.getInputStream();
  43.                 try {
  44.                         BufferedReader rd = new BufferedReader(new InputStreamReader(instream, Charset.forName("UTF-8")));
  45.                         String jsonText = readAll(rd);
  46.                         JSONObject json = new JSONObject(jsonText);
  47.                         return json;
  48.                 } finally {
  49.                         instream.close();
  50.                 }
  51.         }
  52.         public static void main(String[] args) throws IOException, JSONException {
  53.                 // 请求示例 url 默认请求参数已经URL编码处理
  54.                 String url = "https://api-gw.onebound.cn/taobao/item_get/?key=<您自己的apiKey>&secret=<您自己的apiSecret>&num_iid=652874751412&is_promotion=1";
  55.                 JSONObject json = getRequestFromUrl(url);
  56.                 System.out.println(json.toString());
  57.         }
  58. }
复制代码
四、响应参数

六、使用说明

免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。




欢迎光临 ToB企服应用市场:ToB评测及商务社交产业平台 (https://dis.qidao123.com/) Powered by Discuz! X3.4