新浪微博java sdk如何获得一条评论的ID号
2条回答 默认 最新
- long13131462101 2012-03-13 22:48关注
调用GetCategoryFeatures获取可用的Item Condition Definition,然后将某个Condition ID传递给AddItem或ReviseItem call
下面例程基于Java SDK调用GetCategoryFeatures。指定为US站点上编号63861的Category
[code="java"]package com.ebay.test;
import com.ebay.sdk.ApiAccount;
import com.ebay.sdk.ApiContext;
import com.ebay.sdk.ApiCredential;
import com.ebay.sdk.ApiLogging;
import com.ebay.sdk.CallRetry;
import com.ebay.sdk.call.GetCategoryFeaturesCall;
import com.ebay.soap.eBLBaseComponents.CategoryFeatureType;
import com.ebay.soap.eBLBaseComponents.ConditionEnabledCodeType;
import com.ebay.soap.eBLBaseComponents.ConditionType;
import com.ebay.soap.eBLBaseComponents.DetailLevelCodeType;
import com.ebay.soap.eBLBaseComponents.SiteCodeType;public class AppGetCategoryFeatures {
public static ApiContext createApiContext() {
ApiContext apiContext = new ApiContext();
ApiLogging apiLogging = new ApiLogging();
apiContext.setApiLogging(apiLogging);
CallRetry cr = new CallRetry();
cr.setMaximumRetries(3);
cr.setDelayTime(1000); // Wait for one second between each retry-call.String[] apiErrorCodes = new String[] { "502" };
// Set trigger exceptions for CallRetry.
cr.setTriggerApiErrorCodes(apiErrorCodes);// Build a dummy SdkSoapException so that we can get its Class.
Class[] tcs = new Class[] { com.ebay.sdk.SdkSoapException.class };
cr.setTriggerExceptions(tcs);
apiContext.setCallRetry(cr);
apiContext.setTimeout(180000);ApiCredential cred = new ApiCredential();
apiContext.setApiServerUrl("https://api.sandbox.ebay.com/wsapi");
// apiContext.setApiServerUrl("https://api.ebay.com/wsapi");ApiAccount ac = cred.getApiAccount();
ac.setApplication(YOUR-APPID);
ac.setDeveloper(YOUR-DEVID);
ac.setCertificate(YOUR-CERTID);
cred.seteBayToken(YOUR-TOKEN);
apiContext.setApiCredential(cred);return apiContext;
}
private static GetCategoryFeaturesCall getCatFeature(String categoryId, SiteCodeType site) {
GetCategoryFeaturesCall request = new GetCategoryFeaturesCall(
createApiContext());
request.setSite(site);
request.setDetailLevel(new DetailLevelCodeType[] { DetailLevelCodeType.RETURN_ALL });request.setCategoryID(categoryId);
request.setOutputSelector(new String[] {
"Category.ConditionEnabled",
"Category.ConditionValues.Condition.ID",
"Category.ConditionValues.Condition.DisplayName" });try {
request.getCategoryFeatures();
} catch (Exception e) {
e.printStackTrace();
}return request;
}
public static void main(String[] args) {
GetCategoryFeaturesCall cf = getCatFeature("63861", SiteCodeType.US);
/*
- Since we call GetCategoryFeatures for a specified category, so we
- just get the first category element here */
CategoryFeatureType feature = cf.getReturnedCategory()[0];
/*
- If condition Enabled is disabled, then DO NOT pass conditionID in
- AddItem or ReviseItem for this category */
if (feature.getConditionEnabled().equals(ConditionEnabledCodeType.ENABLED)) {
for (ConditionType con : feature.getConditionValues().getCondition())
System.out.println(con.getID() + " - " + con.getDisplayName());
}}
}
[/code]运行代码后,你会看到此Category的Condition ID Definitionf如下所示:1000 - New with tags
1500 - New without tags
1750 - New with defects
3000 - Pre-owned
选择某个condition ID,如"New with tags"。在 AddItem或ReviseItem调用中设置condtionID为 "1000"
[code="java"]AddItemCall request = new AddItemCall(createApiContext());
ItemType item = new ItemType();
item.setConditionID(1000);...
request.setItem(item);
request.addItem();...
[/code]资料地址[url]http://www.ebay.cn/show.php?contentid=4617[/url]本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报
悬赏问题
- ¥15 微信公众号自制会员卡没有收款渠道啊
- ¥15 stable diffusion
- ¥100 Jenkins自动化部署—悬赏100元
- ¥15 关于#python#的问题:求帮写python代码
- ¥20 MATLAB画图图形出现上下震荡的线条
- ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
- ¥15 perl MISA分析p3_in脚本出错
- ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
- ¥15 ubuntu虚拟机打包apk错误
- ¥199 rust编程架构设计的方案 有偿