Teach you step by step how to call e-commerce API to obtain Taobao order data (detailed source code included)

Interface name: seller_order_list-Get the list of sold product orders

taobao.seller_order_list

public parameters

Request address: https://api-sever.cn/taobao/seller_order_list

name type must describe
key String yes Call key (must be spliced ​​into the URL in GET mode)
secret String yes call key
api_name String yes API interface name (included in the request address) [item_search, item_get, item_search_shop, etc.]
cache String no [yes,no] The default is yes, which will call cached data and is faster.
result_type String no [json,jsonu,xml,serialize,var_export] returns the data format, the default is json, the content output by jsonu can be read directly in Chinese
lang String no [cn,en,ru] translation language, default cn simplified Chinese
version String no API version

Request parameters

Settings:page=&tabCode=&dateBegin=&dateEnd=&buyerNick=&itemTitle=&orderId=&lastStartRow=&detail=&page_size=

Parameter description: page: page number
&tabCode:[waitBuyerPay,waitSend,haveSendGoods,refunding,waitRate,success,closed,before3Months]
dateBegin: start time, dateEnd: end time (format: yyyy-mm-dd hh:ii:ss)
buyerNick: Buyer's nickname, if not filled in, it will be the current logged in user
itemTitle: Baby title
orderId: Order number
lastStartRow: Check the parameters used in the order three months ago
detail: This parameter is only supported by advanced users
token: SaaS authorization

How to obtain authorization token:

There are three ways to get the token:
Option 1: Combined interface
 buyer_token_qrcode-get [scan code login method] QR code picture directly click on the interface to get the token and then call the following interface:
 buyer_token_qrcode_ck - get token [scan code login method] 

Option 2: Get token by entering Taobao account password
 buyer_token_create - Get token 

Option 3: Cookie plug-in mode [supports both PC and mobile phones]

response parameters

Version: Date:

name type must Example value describe

order_id

Bigint 0 368830339413001234 order number

deal_time

Date 0 2019-03-06 18:14:25 processing time

buyer_nick

String 0 abc123 Buyer nickname

buyer_name

String 0 Buyer's name

seller_id

Bigint 0 557039353 seller id

goods

Mix 0 [{"goods_name": "Hot PP cotton doll pink pig expression plush toy soft down cotton cute pig pillow elastic girl", "goods_id": "368830339413841880", "goods_image": "//img.alicdn.com/ imgextra/i4/557039353/O1CN010aX1Is2Ixi⼀b0_!!557039353.jpg_sum.jpg", "unit_price": "28.00", "goods_count": "2", "goods_info": "Color classification: big-eyed; height: 40cm (0.4kg)", "goods_code": "qb"}] Product information list

total_price

Float 0 56.00 total price

freight

Float 0 freight

trading_status

String 0 Transaction successful trading status

countdown

String 0 time left

Call example

<?php

// 请求示例 url 默认请求参数已经URL编码处理
// 本示例代码未加密secret参数明文传输,若要加密请参考:api文档
$method = "GET";
$url = "https://api-服务器.cn/taobao/seller_order_list/?key=<您自己的apiKey>&secret=<您自己的apiSecret>&page=&tabCode=&dateBegin=&dateEnd=&buyerNick=&itemTitle=&orderId=&lastStartRow=&detail=&page_size=";
$curl = curl_init();
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST,FALSE);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER,FALSE);
curl_setopt($curl, CURLOPT_FAILONERROR, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, true);
curl_setopt($curl, CURLOPT_ENCODING, "gzip");
var_dump(curl_exec($curl));
?>

 

# coding:utf-8
"""
Compatible for python2.x and python3.x
requirement: pip install requests
"""
from __future__ import print_function
import requests
# 请求示例 url 默认请求参数已经做URL编码
url = "https://api-服务器.cn/taobao/seller_order_list/?key=<您自己的apiKey>&secret=<您自己的apiSecret>&page=&tabCode=&dateBegin=&dateEnd=&buyerNick=&itemTitle=&orderId=&lastStartRow=&detail=&page_size="
headers = {
    "Accept-Encoding": "gzip",
    "Connection": "close"
}
if __name__ == "__main__":
    r = requests.get(url, headers=headers)
    json_obj = r.json()
    print(json_obj)
//using System.Net.Security;
//using System.Security.Cryptography.X509Certificates;
private const String method = "GET";
static void Main(string[] args)
{
	String bodys = "";
	// 请求示例 url 默认请求参数已经做URL编码
	String url = "https://api-服务器.cn/taobao/seller_order_list/?key=<您自己的apiKey>&secret=<您自己的apiSecret>&page=&tabCode=&dateBegin=&dateEnd=&buyerNick=&itemTitle=&orderId=&lastStartRow=&detail=&page_size=";
	HttpWebRequest httpRequest = null;
	HttpWebResponse httpResponse = null; 
	if (url.Contains("https://"))
	{
		ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
		httpRequest = (HttpWebRequest)WebRequest.CreateDefault(new Uri(url));
	}
	else
	{
		httpRequest = (HttpWebRequest)WebRequest.Create(url);
	}
	httpRequest.Method = method;
	if (0 < bodys.Length)
	{
		byte[] data = Encoding.UTF8.GetBytes(bodys);
		using (Stream stream = httpRequest.GetRequestStream())
		{
		stream.Write(data, 0, data.Length);
		}
	}
	try
	{
		httpResponse = (HttpWebResponse)httpRequest.GetResponse();
	}
	catch (WebException ex)
	{
		httpResponse = (HttpWebResponse)ex.Response;
	}
	Console.WriteLine(httpResponse.StatusCode);
	Console.WriteLine(httpResponse.Method);
	Console.WriteLine(httpResponse.Headers);
	Stream st = httpResponse.GetResponseStream();
	StreamReader reader = new StreamReader(st, Encoding.GetEncoding("utf-8"));
	Console.WriteLine(reader.ReadToEnd());
	Console.WriteLine("\n");
}
public static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
{
	return true;
}

Guess you like

Origin blog.csdn.net/Jernnifer_mao/article/details/132709663
Recommended