1

我想从我的应用程序中在 google plus wall 中分享一些信息。我正在尝试 moment.insert,但出现 400 错误。有人可以帮我吗

@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错误??任何人都可以告诉我.....哪里错了..!!`

4

2 回答 2

4

目前,无法以编程方式写入用户的 Stream。作为开发人员,您有两种选择:

  1. 编写一个 AppActivity(以前称为 Moment),它将信息写入 Google,但不会写入 Google+ 流。这些活动在 plus.google.com/apps 上可见,并且随着时间的推移 Google 将以其他方式使用。
  2. 创建一个用户必须启动的交互式帖子共享按钮。但是,您可以预先填写帖子的文本和最多 10 个预期收件人。用户可以根据需要进行更改,然后执行实际共享。您可以在https://developers.google.com/+/web/share/interactive或观看此 Google+ 开发者直播剧集了解更多信息: http ://www.youtube.com/watch?v=U4Iw28jWtAY 。
于 2013-04-10T00:38:14.840 回答
4

从文档中不清楚,但您不能同时提供target.url和大多数其他target元数据。这目前在问题跟踪系统中作为错误 485打开- 请前往那里并为问题加注星标,以确保他们正确地确定修复的优先级。

如果您删除该target.url值并添加一个target.id值,它应该可以工作。

(顺便说一句,这不会在用户的信息流中发布,但会在他们的应用时刻库中发布应用活动。如果他们选择,他们必须手动共享活动。)

于 2013-04-09T11:22:20.563 回答