简体   繁体   English

如何与“ eBay查找APi”一起使用

[英]How to work with the “eBay finding APi”

I`m relatively new to programming and I´m completely new to Stack overflow, so please be patient with me! 我是编程的新手,而Stack Overflow则是新手,所以请耐心等待! Currently I work on a ASP.NET MVC project including the Ebay finding API. 目前,我正在一个ASP.NET MVC项目中工作,其中包括Ebay查找API。

The goal i want to accomplish is to create a Website on which you can search for different articles on Ebay and being able to use certain filters using the Ebay finding API. 我要实现的目标是创建一个网站,您可以在该网站上搜索Ebay上的不同文章,并能够使用Ebay查找API使用某些过滤器。 This is a training projekt for me, as the C# part of the whole thing is a good practice in my opinion. 对我来说,这是一个培训项目,因为在我看来,整件事的C#部分都是不错的做法。 Unfortunately I´m stuck with the whole API connection to ebay part and havent done any C# programming myself. 不幸的是,我坚持将整个API连接到ebay部分,并且自己还没有完成任何C#编程。 Frankly i have no idea what im doing and I hope some of you may have an idea or some tips for me. 坦白说,我不知道自己在做什么,我希望你们中的一些人对我有想法或一些技巧。 I know I might be vague and I´m sorry, but i´m just at the beginning of programming. 我知道我可能会很模糊,很抱歉,但是我才刚刚开始编程。

What have i done so far? 到目前为止,我做了什么?

I already registered on the ebay developers program and I already have my App ID, the Dev IDm the Cert ID and a Token. 我已经在ebay开发人员计划中注册,并且已经拥有我的应用程序ID,开发ID,证书ID和令牌。

Important: I currently only work with the sandbox! 重要提示:我目前仅使用沙箱!

I found a piece of code online which I´m using, but now im stuck. 我在网上找到了一段正在使用的代码,但现在被卡住了。 Obisously i filled in the IDs and the token but deleted it for this post. 奇怪的是,我填写了ID和令牌,但为这篇文章删除了它。 In the "Index" class at the end of my piece of code I entered the ID of a random Ebay article for testing purposes. 在我的代码末尾的“索引”类中,我输入了用于测试目的的随机Ebay文章的ID。 When i debug I get this Exception: 当我调试时,出现此异常:

"eBay.Service.Core.Sdk.ApiException: 'This item cannot be accessed because the listing has been deleted, is a Half.com listing, or you are not the seller." “ eBay.Service.Core.Sdk.ApiException:由于该列表已被删除,Half.com列表或您不是卖方,因此无法访问此项目。”

I would really appreciate if someone can show me how to do it correctly or push me in the right direction. 如果有人可以告诉我如何正确执行操作或向正确的方向推动我,我将不胜感激。 I have to admit that i find the whole Ebay API documentation etc. to be very confusing and I dind´t find any advice on how to start. 我必须承认,我发现整个Ebay API文档等都非常令人困惑,而且我没有找到有关启动的任何建议。 I take any advice you guys can give me! 我接受你们可以给我的任何建议!

Here is the code I found and used so far: 这是我到目前为止找到并使用的代码:

    using System;    
    using System.Collections.Generic;    
    using System.Linq;    
    using System.Web;    
    using System.Web.Mvc;    
    using System.Windows.Forms;   
    using System.Resources;    
    using eBay.Service.Call;    
    using eBay.Service.Core.Sdk;    
    using eBay.Service.Core.Soap;    

namespace Ebay_API_Neu.Controllers    
    {
        public class HomeController : Controller    
    {   
    public GetItemCall getItemDataFromEbay(String itemId)    
    {    
    ApiContext oContext = new ApiContext();

    oContext.ApiCredential.ApiAccount.Developer = "//dev ID"; // use your dev ID

    oContext.ApiCredential.ApiAccount.Application = "//App ID"; // use your app ID

    oContext.ApiCredential.ApiAccount.Certificate = "//cert ID"; // use your cert ID

    oContext.ApiCredential.eBayToken = "//Token"; //set the AuthToken

    oContext.SoapApiServerUrl = "https://api.sandbox.ebay.com/wsapi";

    //set the Site of the Context

    oContext.Site = eBay.Service.Core.Soap.SiteCodeType.Germany;

    //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;    
    }    
    public ActionResult Index()    
    {    
    getItemDataFromEbay("173354849991");

    return View();   
    }

From the error you are getting I would guess that you are trying to get information regarding a "random listing" you have not entered yourself on the eBay sandbox. 从您收到的错误中,我猜您正在尝试获取有关尚未在eBay沙箱中输入自己的“随机列表”的信息。 In order to use GetItem the listing you are retrieving has to have been created using your sandbox user id. 为了使用GetItem,必须使用沙箱用户ID创建要检索的列表。

Take a look at the below link to API doc for GetItem() - specifically the requirements for "Testing GetItem". 请看下面指向GetItem()的API文档的链接-特别是“测试GetItem”的要求。 If you think I might be correct then try creating a listing in the sandbox using either the Web Interface or eBay API AddItem() before retrieving it with GetItem(). 如果您认为我可能是正确的,请尝试使用Web Interface或eBay API AddItem()在沙箱中创建列表,然后再使用GetItem()进行检索。

https://developer.ebay.com/devzone/xml/docs/reference/ebay/getitem.html https://developer.ebay.com/devzone/xml/docs/reference/ebay/getitem.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM