C++获取阿里巴巴1688中国站店铺详情 API 接口返回值示例说明

发布时间 2023-05-04 17:01:19作者: API测试开发Cris

C++(c plus plus)是一种计算机高级程序设计语言,由C语言扩展升级而产生,最早于1979年由本贾尼·斯特劳斯特卢普在AT&T贝尔工作室研发。

C++既可以进行C语言的过程化程序设计,又可以进行以抽象数据类型为特点的基于对象的程序设计,还可以进行以继承和多态为特点的面向对象的程序设计。C++擅长面向对象程序设计的同时,还可以进行基于过程的程序设计。 C++几乎可以创建任何类型的程序:游戏、设备驱动程序、HPC、云、桌面、嵌入式和移动应用等。 甚至用于其他编程语言的库和编译器也使用C++编写。 

C++拥有计算机运行的实用性特征,同时还致力于提高大规模程序的编程质量与程序设计语言的问题描述能力。

C++请求示例

#include<iostream>
#include<string>
#include<curl/curl.h>

using namespace std;

static size_t Data(void *ptr, size_t size, size_t nmemb, string *stream)
{
    std::size_t realSize = size *nmemb;
    auto *realPtr = reinterpret_cast<char *>(ptr);

    for (std::size_t i=0;i<realSize;++i) {
        *(stream) += *(realPtr + i);
    }

    return realSize;
}

int main(){

     CURL *curl;
     CURLcode result;
     string readBuffer;
     curl = curl_easy_init();

     if(curl) {

         curl_easy_setopt(curl, CURLOPT_URL, "https://=v-;18870288846/1688/seller_info/?key=<您自己的apiKey>&secret=<您自己的apiSecret>&seller_id=2206619673102");
         curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
         curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, Data);
         curl_easy_setopt(curl, CURLOPT_WRITEDATA, &readBuffer);

         result = curl_easy_perform(curl);

         if(result == CURLE_OK) {
             cout<<readBuffer<<endl;
         }else{
             cerr<<"curl_easy error:"<<curl_easy_strerror(result)<<endl;
         }

         curl_easy_cleanup(curl);
     }
     return 0;
}

响应示例

{
	"user": {
		"id": "950078515",
		"nick": "余姚市联盛模塑厂",
		"good_num": null,
		"level": "1",
		"created": "2009年03月23日",
		"shop_type": "个体经营",
		"user_num_id": "yylsmould",
		"company_id": "92330281MA2EP3DC93",
		"company_dj": "余姚市市场监督管理局",
		"company_time": "2009-03-23 至 长期",
		"company_info": {
			"comapnyInfo": {
				"annualRevenue": "人民币 701 万元/年 - 1000 万元/年",
				"factorySize": "2800平方米",
				"manufactureType": "OEM加工、ODM加工",
				"productionCapacity": "600000件",
				"productionUnit": "件",
				"qaQc": "内部",
				"rndStaffNum": "5 - 10 人",
				"technologyType": "注塑/注射"
			},
			"itemList": [
				{
					"itemName": "厂房面积",
					"itemValue": "2800平方米"
				},
				{
					"itemName": "研发人数",
					"itemValue": "5 - 10 人"
				},
				{
					"itemName": "加工方式",
					"itemValue": "OEM加工、ODM加工"
				},
				{
					"itemName": "加工工艺",
					"itemValue": "注塑/注射"
				},
				{
					"itemName": "月产量",
					"itemValue": "600000件"
				},
				{
					"itemName": "年营业额",
					"itemValue": "人民币 701 万元/年 - 1000 万元/年"
				},
				{
					"itemName": "质量控制",
					"itemValue": "内部"
				}
			]
		},
		"cid": "-1",
		"sid": "yylsmould",
		"pic_url": null,
		"video": null,
		"title": "余姚市联盛模塑厂",
		"address": "中国浙江宁波余姚市凤山街道五星村上峰岭15号(自主申报)",
		"phone": "13429262679",
		"zhuy": "https://yylsmould.1688.com./page/contactinfo.htm",
		"fh_score": "-0.15",
		"hm_score": "0.02",
		"xy_score": "-0.13",
		"ht_score": "0.36",
		"menu": "一般经营项目:模具的制造;塑料制品的加工;第一类医疗器械的制造。"
	},
	"secache": "fae723b33d52c0870fda3ba6b0c5b577",
	"secache_time": 1614932379,
	"secache_date": "2021-03-05 16:19:39",
	"translate_status": "",
	"translate_time": 0,
	"language": {
		"default_lang": "cn",
		"current_lang": "cn"
	},
	"error": "",
	"reason": "",
	"error_code": "0000",
	"cache": 1,
	"api_info": "today:7 max:10000",
	"execution_time": 0.062,
	"server_time": "Beijing/2021-03-09 16:55:39",
	"client_ip": "106.6.35.144",
	"call_args": {
		"shop_url": "https://yylsmould.1688.com"
	},
	"api_type": "1688",
	"translate_language": "zh-CN",
	"translate_engine": "google_cn",
	"server_memory": "3.52MB",
	"request_id": "gw-4.6047380bae9e5"
}

异常示例

{
  "error": "item-not-found",
  "reason": "商品没找到",
  "error_code": "2000",
  "success": 0,
  "cache": 0,
  "api_info": "today:0 max:10000",
  "execution_time": 0.081,
  "server_time": "Beijing/2020-06-10 23:44:00",
  "call_args": [],
  "api_type": "taobao",
  "request_id": "15ee0ffc041242"}

请求参数测试

请求参数:seller_id=2206619673102

参数说明:seller_id:卖家id

响应参数

Version: Date:

名称类型必须示例值描述

items

items[] 0   按关键字搜索商品

id

String 0 950078515 店铺id

nick

String 0 余姚市联盛模塑厂 卖家昵称

good_num

String 0    

level

String 0 1  

created

String 0 2009年03月23日  

shop_type

String 0 个体经营 店铺类型

user_num_id

String 0 yylsmould  

company_id

String 0 92330281MA2EP3DC93  

company_dj

String 0 余姚市市场监督管理局  

company_time

String 0 2009-03-23 至 长期  

company_info

Mix 0 company_info[] 公司信息

cid

String 0    

sid

String 0 yylsmould 店铺ID

pic_url

String 0    

video

String 0    

title

String 0 余姚市联盛模塑厂 店铺标题

address

String 0 中国浙江宁波余姚市凤山街道五星村上峰岭15号(自主申报) 卖家详细地址

phone

String 0 more接口v-;18870288846  

zhuy

String 0 https://yylsmould.1688.com./page/contactinfo.htm 店铺主页

fh_score

String 0 0.11  

hm_score

String 0 0.02  

xy_score

String 0 -0.06  

ht_score

String 0 0.41  

menu

String 0 一般经营项目:模具的制造;塑料制品的加工;第一类医疗器械的制造。

文章内容有限,欢迎广大码友私信沟通交流!