飞猪it 2012-03-13 22:43 采纳率: 0%
浏览 301
已采纳

新浪微博java sdk如何获得一条评论的ID号

新浪微博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]

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥30 帮我写一段可以读取LD2450数据并计算距离的Arduino代码
  • ¥15 C#调用python代码(python带有库)
  • ¥15 矩阵加法的规则是两个矩阵中对应位置的数的绝对值进行加和
  • ¥15 活动选择题。最多可以参加几个项目?
  • ¥15 飞机曲面部件如机翼,壁板等具体的孔位模型
  • ¥15 vs2019中数据导出问题
  • ¥20 云服务Linux系统TCP-MSS值修改?
  • ¥20 关于#单片机#的问题:项目:使用模拟iic与ov2640通讯环境:F407问题:读取的ID号总是0xff,自己调了调发现在读从机数据时,SDA线上并未有信号变化(语言-c语言)
  • ¥20 怎么在stm32门禁成品上增加查询记录功能
  • ¥15 Source insight编写代码后使用CCS5.2版本import之后,代码跳到注释行里面