首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >eBay GetMyeBaySellings在XML请求中找不到XML <RequestPassword>或<RequestToken>

eBay GetMyeBaySellings在XML请求中找不到XML <RequestPassword>或<RequestToken>
EN

Stack Overflow用户
提问于 2019-07-06 23:52:35
回答 2查看 212关注 0票数 0

我想使用eBay-API来获取我已售出的商品。下面是我的代码:

代码语言:javascript
复制
ApiContext apiContext = new ApiContext();
ApiCredential credential = apiContext.getApiCredential();
ApiAccount acc = new ApiAccount();
acc.setApplication("app-id");
acc.setDeveloper("dev-id");
acc.setCertificate("cert");
eBayAccount eBayAccount = new eBayAccount();
eBayAccount.setPassword("ebay user");
eBayAccount.setUsername("ebay password");
credential.setApiAccount(acc);
credential.seteBayAccount(eBayAccount);
apiContext.setApiServerUrl("https://api.ebay.com/wsapi");
GetMyeBaySellingCall call = new GetMyeBaySellingCall(apiContext);
GetMyeBaySellingRequestType requestType = new GetMyeBaySellingRequestType();
call.setMyeBaySellingRequest(requestType);
ItemListCustomizationType lc = new ItemListCustomizationType();
lc.setInclude(new Boolean(true));
lc.setIncludeNotes(new Boolean(true));
lc.setSort(ItemSortTypeCodeType.BID_COUNT);
requestType.setActiveList(lc);

lc = new ItemListCustomizationType();
lc.setInclude(new Boolean(true));
lc.setIncludeNotes(new Boolean(true));
lc.setSort(ItemSortTypeCodeType.PRICE);
requestType.setSoldList(lc);

lc = new ItemListCustomizationType();
lc.setInclude(new Boolean(true));
lc.setIncludeNotes(new Boolean(true));
lc.setSort(ItemSortTypeCodeType.END_TIME);
requestType.setUnsoldList(lc);

lc = new ItemListCustomizationType();
lc.setInclude(new Boolean(true));
lc.setIncludeNotes(new Boolean(true));
lc.setSort(ItemSortTypeCodeType.START_TIME);
requestType.setScheduledList(lc);

call.getMyeBaySelling();

GetMyeBaySellingResponseType resp = call.getReturnedMyeBaySellingResponse();

APIAccount是用来自ebay开发者站点的数据配置的,eBayAccount是我想要获取项目的帐户的凭据。但是,这会导致以下异常:

代码语言:javascript
复制
Exception in thread "main" com.ebay.sdk.SdkSoapException: No XML <RequestPassword> or <RequestToken> was found in XML Request.
    at com.ebay.sdk.SdkSoapException.fromSOAPFaultException(Unknown Source)
    at com.ebay.sdk.ApiCall.executeByApiName(Unknown Source)
    at com.ebay.sdk.ApiCall.execute(Unknown Source)
    at com.ebay.sdk.call.GetMyeBaySellingCall.getMyeBaySelling(GetMyeBaySellingCall.java:150)

用户通过了应用程序的身份验证,并且API-URL正确。此外,应用程序和用户已针对生产进行了身份验证。

EN

回答 2

Stack Overflow用户

发布于 2019-12-26 06:48:19

我想给出一个更详细的例子。我的应用程序从eBay为我的帐户(仅限我的帐户)下载订单。在这种情况下,我不需要提供应用程序ID、开发人员ID或证书ID,我只需要在eBay上生成Auth'n'Auth令牌并将其用作我的凭据。

Azure函数:

代码语言:javascript
复制
@FunctionName("LoadOrders")
public void run(@TimerTrigger(name = "keepAliveTrigger", schedule = "0 5 3 3 * *") String timerInfo, ExecutionContext context)
        throws ApiException, SdkException, Exception {

    ZonedDateTime startDate = ZonedDateTime.now(Constants.TIMEZONE)
        .minusMonths(1)
        .with(TemporalAdjusters.firstDayOfMonth())
        .withHour(0)
        .withMinute(0)
        .withSecond(0)
        .withNano(0);

    ZonedDateTime endDate = ZonedDateTime.now(Constants.TIMEZONE)
        .with(TemporalAdjusters.firstDayOfMonth())
        .withHour(0)
        .withMinute(0)
        .withSecond(0)
        .withNano(0)
        .minusSeconds(1);

    GetOrdersCall call = new GetOrdersCall(apiContext());
    call.setCreateTimeFrom(GregorianCalendar.from(startDate));
    call.setCreateTimeTo(GregorianCalendar.from(endDate));

    for (OrderType orderType : call.getOrders()) {
        System.out.println(orderType);
    }
}

apiContext()方法的定义如下:

代码语言:javascript
复制
public final static String EBAY_TOKEN = "AgAAAA**AQAA.....a4A9t+/";

public final static String API_SERVER_URL = "https://api.ebay.com/wsapi";

private ApiContext apiContext() {
    // credential
    ApiCredential credential = new ApiCredential();
    credential.seteBayToken(EBAY_TOKEN);

    // context
    ApiContext apiContext = new ApiContext();
    apiContext.setApiCredential(credential);
    apiContext.setApiServerUrl(API_SERVER_URL);
    apiContext.setCallRetry(callRetry());

    return apiContext;
}

以防你需要它..。

代码语言:javascript
复制
private CallRetry callRetry() {
    CallRetry retry = new CallRetry();
    retry.setMaximumRetries(3);
    retry.setDelayTime(3000);
    return retry;
}

您可以在https://developer.ebay.com/my/auth/?env=production获取"eBay token“(截止到2019年12/25)。

下面是屏幕的样子:

票数 0
EN

Stack Overflow用户

发布于 2019-08-19 20:18:48

代码语言:javascript
复制
        ApiContext apiContext = new ApiContext();
        ApiCredential credential = apiContext.getApiCredential();
        credential.seteBayToken("token from developer central");
        apiContext.setApiServerUrl("https://api.ebay.com/wsapi");
        GetMyeBaySellingCall call = new GetMyeBaySellingCall(apiContext);
票数 -1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56915611

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档