【发布时间】:2014-06-29 19:53:08
【问题描述】:
我注册了 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、runQuery、fetch 和 get返回 JSON 响应的方法。
【问题讨论】:
标签: java json get-request