我想分享一些信息在谷歌加牆從我的application.and我試圖爲moment.insert,但得到400錯誤。有人可以幫我如何使用谷歌加在api中的用戶的流在java中發佈
@Override
public JSONObject getGooglePlusAddUseractivities(Object token) {
Token accessToken = (Token) token;
OAuthService service = createOAuthServiceForGooglePlus();
OAuthRequest request = new OAuthRequest(Method.POST,"https://www.googleapis.com/plus/v1/people/me/moments/vault");
request.addQuerystringParameter("alt", "json");
service.signRequest(accessToken, request);
JSONObject object=new JSONObject();
try {
object.put("kind","plus#moment");
object.put("type","http://schemas.google.com/AddActivity");
JSONObject obj1=new JSONObject();
obj1.put("kind", "plus#itemScope");
obj1.put("url","https://plus.google.com/me");
obj1.put("description","Sign up now to claim and redeem your credits while shopping! ");
obj1.put("image","http://invite.png");
obj1.put("contentUrl", "www.abcd.com");
obj1.put("thumbnailUrl", "http://logo1_favicon.png");
object.putOpt("target", obj1);;
}catch(Exception ex) {
ex.printStackTrace();
}
request.addPayload(object.toString());
request.addHeader("Content-Type", "application/json");
System.out.println("request : "+request.getBodyContents());
Response response = request.send();
String responseBody = response.getBody();
JSONObject googleJSON = null;
try {
googleJSON = new JSONObject(responseBody);
}
catch (JSONException e) {
System.out.println("can not create JSON Object");
}
得到400錯誤?任何人都可以告訴我.....哪裏錯了.. !!
thnx囚犯。我已經修復了這個私有靜態最終String AUTHORIZE_URL =「https://accounts.google.com/o/oauth2/auth?client_id=%s&redirect_uri=%s&response_type=code&request_visible_actions=http://schemas.google.com/ AddActivity&ACCESS_TYPE =離線「;我沒有在授權url中提及request_visible_actions。現在代碼正在工作,但不會在用戶的流上發佈。你能幫我嗎? – dinesh 2013-04-09 16:53:25
我不完全確定你現在在說什麼。聽起來像是最好開始另一個問題。 – Prisoner 2013-04-09 19:10:35