0

我注册了 semantics3 API,以便可以使用他们的 UPC/EAN 产品搜索功能,并且我收到了我的 APIkey 和 APIsecret。现在,我想发出一个 propper Get 请求来测试它,然后最终将它合并到我自己的应用程序中。我从他们的 GitHub 页面下载了 semantics3 java 项目。

无论如何,我如何使用自己的 UPC 或 EAN 代码实际进行 UPC/EAN 查询,以便获得我正在搜索的产品的 JSON 响应?

Semantics3Request 的构造函数如下所示:

public Semantics3Request(String apiKey, String apiSecret, String endpoint) {
    if (apiKey == null) { 
        throw new Semantics3Exception(
                "API Credentials Missing",
                "You did not supply an apiKey. Please sign up at https://semantics3.com/ to obtain your api_key."
            );
    }
    if (apiSecret == null) { 
        throw new Semantics3Exception(
                "API Credentials Missing",
                "You did not supply an apiSecret. Please sign up at https://semantics3.com/ to obtain your api_key."
            );
    }

    this.apiKey    = apiKey;
    this.apiSecret = apiSecret;
    this.endpoint  = endpoint;
    this.consumer = new DefaultOAuthConsumer(apiKey, apiSecret);
    consumer.setTokenWithSecret("", "");
}

一件很重要的事情是,我不明白我应该在其中添加什么,String endpoint以便以后可以调用 Sematics3Request 类中的方法:、add和返回JSON 响应的方法。runQueryfetchget

4

1 回答 1

0

您可以尝试使用此代码进行 UPC 搜索

    //To include, Github: https://github.com/Semantics3/semantics3-java
import com.semantics3.api.Products;

Products products = new Products(
    "SEM3xxxxxxxxxxxxxxxxxxxxxx",
    "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
);

products
    .productsField( "upc", "934586730023" )
JSONObject results = products.getProducts();
System.out.println(results);

您也可以访问http://semantics3.com以获得更多帮助

于 2015-03-27T09:58:23.200 回答