我一直在向Glass发送简单的消息非常困难,我怀疑它与授权请求有关。以下是我的代码:向Google Glass发送文本的授权
String AUTH="ya29.1.AADtN_WhePFbTxZdrM8wDWaVyBPgpyvph5EifU-CDQ4z9nbJxBXHLQLiaY3EDBk";
for (int i=5; i>0; i--)
{
String url = "https://www.googleapis.com/mirror/v1/timeline?fields=text";
URL obj = new URL(url);
HttpsURLConnection con = (HttpsURLConnection) obj.openConnection();
con.setRequestMethod("POST");
con.setRequestProperty("X-JavaScript-User-Agent", "Google APIs Explorer");
con.setRequestProperty("Authorization", "Bearer " + AUTH);
con.setRequestProperty("Content-Type", "application/json");
con.setRequestProperty("Content-Length", "26");
String urlParameters = "{ \"text\": \"Hello world\" }";
不幸的是,它一直抛出403错误。有什么建议?谢谢。
呃,关闭打呵欠for循环? –
它已关闭。这是代码的摘录。 – user3028927