我有一个 Klout 的 API 密钥,我编写了一个每天执行 6 次调用的服务,以跟踪 6 个社交媒体帐户的性能。该服务上周突然停止工作。
这是我帐户上的日志的概述:
我混淆了我的密钥,但如您所见,我的 Starter Plan 的状态是活动的;但是:错误显示403 inactive Plan (Proxy):
java.io.IOException: Server returned HTTP response code: 403 for URL: http://api.klout.com/v2/identity.json/twitter?screenName=redacted&key=redacted
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1876)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1474)
at com.directmediatips.klout.KloutRequests.sendRequest(KloutRequests.java:66)
at com.directmediatips.klout.Klout.getUserIdFromTwitterScreenName(Klout.java:119)
at com.directmediatips.klout.Klout.main(Klout.java:126)
在它说的地方redacted
,有一个 Twitter 句柄和一个 API 密钥。
构造函数和相关方法是:
private String apiKey;
public Klout(String apiKey) {
this.apiKey = apiKey;
}
public UserId getUserIdFromTwitterScreenName(String screenName) throws IOException {
return new UserId(new JSONObject(KloutRequests.sendRequest(String.format(
KloutRequests.ID_FROM_TWITTER_SCREENNAME, screenName, apiKey))));
}
public static String sendRequest(String request) throws IOException {
URL url = new URL(request);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("GET");
connection.setUseCaches(false);
BufferedReader in = new BufferedReader(
new InputStreamReader(connection.getInputStream()));
String line;
StringBuilder response = new StringBuilder();
while ((line = in.readLine()) != null) {
response.append(line);
}
in.close();
return response.toString();
}
我唯一能想到的是,Klout 停用了我的帐户,但是当我登录 Klout 时,这并没有反映在我的帐户面板中,但也许我在我的代码中忽略了一些非常简单的东西。指标还显示,我每天拨打的电话从未超过 6 次,这远低于关键速率限制。