gpt4 book ai didi

c# - 如何使用ebay api请求产品?

转载 作者:太空狗 更新时间:2023-10-30 01:23:55 24 4
gpt4 key购买 nike

如何调用 eBay 并请求它返回搜索结果数组?

这是我到目前为止想出的:

string endpoint = "https://api.ebay.com/wsapi";
string siteId = "0";
string appId = "*"; // use your app ID
string devId = "*"; // use your dev ID
string certId = "*"; // use your cert ID
string version = "405";

string requestURL = endpoint
+ "?callname=FindProducts"
+ "&siteid=" + siteId
+ "&appid=" + appId
+ "&version=" + version
+ "&routing=default"
+ "&AvailableItemsOnly=true"
+ "&QueryKeywords=nvidia"
+ "&itemFilter(0).name=ListingType"
+ "&itemFilter(0).value(0)=FixedPrice"
+ "&itemFilter(0).value(1)=Auction"
+ "&CategoryID=27386";

我如何将它包装到请求中并以某种数据结构获得响应?我已经拿到了 SDK。

最佳答案

我需要使用 eBay 查找 API;

    public GetItemCall getItemDataFromEbay(String itemId)
{
ApiContext oContext = new ApiContext();
oContext.ApiCredential.ApiAccount.Developer = ""; // use your dev ID
oContext.ApiCredential.ApiAccount.Application = ""; // use your app ID
oContext.ApiCredential.ApiAccount.Certificate = ""; // use your cert ID
oContext.ApiCredential.eBayToken = ""; //set the AuthToken

//set the endpoint (sandbox) use https://api.ebay.com/wsapi for production
oContext.SoapApiServerUrl = "https://api.ebay.com/wsapi";

//set the Site of the Context
oContext.Site = eBay.Service.Core.Soap.SiteCodeType.US;

//the WSDL Version used for this SDK build
oContext.Version = "735";

//very important, let's setup the logging
ApiLogManager oLogManager = new ApiLogManager();
oLogManager.ApiLoggerList.Add(new eBay.Service.Util.FileLogger("GetItem.log", true, true, true));
oLogManager.EnableLogging = true;
oContext.ApiLogManager = oLogManager;

GetItemCall oGetItemCall = new GetItemCall(oContext);

//' set the Version used in the call
oGetItemCall.Version = oContext.Version;

//' set the Site of the call
oGetItemCall.Site = oContext.Site;

//' enable the compression feature
oGetItemCall.EnableCompression = true;
oGetItemCall.DetailLevelList.Add(eBay.Service.Core.Soap.DetailLevelCodeType.ReturnAll);
oGetItemCall.ItemID = itemId;
try
{
oGetItemCall.GetItem(oGetItemCall.ItemID);
}
catch (Exception E)
{
Console.Write(E.ToString());
oGetItemCall.GetItem(itemId);
}
GC.Collect();
return oGetItemCall;
}

关于c# - 如何使用ebay api请求产品?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10857790/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com