我注册了UPC,这样我就可以使用他们的semantics3 /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、runQuery、fetch和返回JSON响应的get方法。
发布于 2015-03-27 17:58:23
您可以尝试使用此代码进行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获取更多帮助
https://stackoverflow.com/questions/23609251
复制相似问题