作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想使用 eBay-API 来获取我售出的商品。这是我的代码:
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
填充了我想要为其获取项目的帐户的凭据。但是,这会导致以下异常:
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 正确。此外,应用程序和用户都经过生产身份验证。
最佳答案
我想举一个更详细的例子。我的应用程序从 eBay 下载我的帐户的订单(仅限我的帐户)。在这种情况下,我不需要提供 App ID、Dev ID 或 Cert ID。我只需要在 eBay 上生成 Auth'n'Auth token 并将其用作我的凭据。
Azure 功能:
@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()
方法定义如下:
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;
}
以防万一您需要它......
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 日)。
屏幕如下所示:
关于java - eBay GetMyeBaySellings 在 XML 请求中找不到 XML <RequestPassword> 或 <RequestToken>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56915611/
我想使用 eBay-API 来获取我售出的商品。这是我的代码: ApiContext apiContext = new ApiContext(); ApiCredential credential =
我是一名优秀的程序员,十分优秀!