登录
退出
首页
开放版图
苏宁有货
商家后台
文档中心
文档中心
API文档
消息中心
平台公告
工单
我的工单
提交工单
控制台
SDK调用示例
suning.custom.shoppingcart.query/
调用示例(JAVA)
复制全部代码
import com.suning.api.entity.custom.ShoppingcartQueryRequest; import com.suning.api.entity.custom.ShoppingcartQueryResponse; ShoppingcartQueryRequest request = new ShoppingcartQueryRequest(); CommodityList commodityList= new CommodityList(); commodityList.setCmmdtyCode("11761222626"); commodityList.setCmmdtyName("商品名称"); commodityList.setCmmdtyQty("1"); commodityList.setShopCode("1111111111"); List
commodityListList =new ArrayList
(); commodityListList.add(commodityList); request.setCommodityList(commodityListList); request.setOperationEquipment("01"); request.setOperationTerminal("01"); request.setSnUnionId("f3ff95c0a701ecbd0fa13edbe21ff3ff95c12a701ecbb0fa"); request.setXzActivityId("20032412072321366607"); //api入参校验逻辑开关,当测试稳定之后建议设置为 false 或者删除该行 request.setCheckParam(true); String serverUrl = "https://openpre.cnsuning.com/api/http/sopRequest"; String appKey = "你的appKey"; String appSecret = "你的appSecret"; DefaultSuningClient client = new DefaultSuningClient(serverUrl, appKey,appSecret, "json"); try { ShoppingcartQueryResponse response = client.excute(request); System.out.println("返回json/xml格式数据 :" + response.getBody()); } catch (SuningApiException e) { e.printStackTrace(); }
调用示例(PHP)
复制全部代码
$req = new ShoppingcartQueryRequest(); $commodityList= new CommodityList(); $commodityList-> setCmmdtyCode("11761222626"); $commodityList-> setCmmdtyName("商品名称"); $commodityList-> setCmmdtyQty("1"); $commodityList-> setShopCode("1111111111"); $req -> setCommodityList(array($commodityList)); $req -> setOperationEquipment("01"); $req -> setOperationTerminal("01"); $req -> setSnUnionId("f3ff95c0a701ecbd0fa13edbe21ff3ff95c12a701ecbb0fa"); $req -> setXzActivityId("20032412072321366607"); //api入参校验逻辑开关,当测试稳定之后建议设置为 false 或者删除该行 $req -> setCheckParam('true'); $serverUrl = "https://openpre.cnsuning.com/api/http/sopRequest"; $appKey = "你的appKey"; $appSecret = "你的appSecret"; $client = new DefaultSuningClient($serverUrl,$appKey,$appSecret,'json'); $resp = $client -> execute($req); print_r("返回响应报文:".$resp);
调用示例(.NET)
复制全部代码
using suning_api_sdk.BizRequest.CustomCustomRequest; using suning_api_sdk.BizResponse.CustomCustomResponse; using suning_api_sdk.Models.CustomCustomModel; ShoppingcartQueryRequest request = new ShoppingcartQueryRequest(); ShoppingcartQueryCommodityListReq commodityList= new ShoppingcartQueryCommodityListReq(); commodityList.cmmdtyCode="11761222626"; commodityList.cmmdtyName="商品名称"; commodityList.cmmdtyQty="1"; commodityList.shopCode="1111111111"; List
commodityListList =new ArrayList
(); commodityListList.add(commodityList); request.commodityList=commodityListList; request.operationEquipment="01"; request.operationTerminal="01"; request.snUnionId="f3ff95c0a701ecbd0fa13edbe21ff3ff95c12a701ecbb0fa"; request.xzActivityId="20032412072321366607"; //开启日志调试,当测试稳定之后建议设置为 false 或者删除该行 SuningLogger.IsLogDebug = true; string serverUrl = "https://openpre.cnsuning.com/api/http/sopRequest"; string appKey = "你的appKey"; string appSecret = "你的appSecret"; ISuningClient client = new DefaultSuningClient(serverUrl, appKey,appSecret); ShoppingcartQueryResponse response = client.Execute(request);
调用示例(PYTHON)
复制全部代码
# -*- coding: utf-8 -*- import suning.api request = suning.api.custom.ShoppingcartQueryRequest() request. commodityList= [{ cmmdtyCode:"11761222626", cmmdtyName:"商品名称", cmmdtyQty:"1", shopCode:"1111111111", }]; request.operationEquipment="01"; request.operationTerminal="01"; request.snUnionId="f3ff95c0a701ecbd0fa13edbe21ff3ff95c12a701ecbb0fa"; request.xzActivityId="20032412072321366607"; domain = "https://openpre.cnsuning.com" appKey = "你的appKey" appSecret = "你的appSecret" request.setDomainInfo(domain,"80") request.setAppInfo(appKey,appSecret) try: result=request.getResponse() print(result) except Exception as e: print(e)