2016-08-15 86 views
2

我想要从Android应用程序发布状态,该状态包含一个图像,一些人在其中标记。当我发布状态时,只有带有标签的人或只有照片才能发挥作用,它工作得很好。问题出在我添加带有标签的照片然后发布在fb上时,我的个人资料中什么也没有显示。图形API照片上传与朋友标记

btn_submit.setOnClickListener(new View.OnClickListener() { 
     @Override 
     public void onClick(View v) { 
      for (String s : user_friends_id) { 
       ids += s + ","; 
      } 
      if (etxt_status.getText().toString().equals("")) { 
       Toast.makeText(FacebookStatusUpdate.this, "Status is Empty", Toast.LENGTH_SHORT).show(); 
      } else /*if (bitmapdata != null)*/ { 
       btn_submit.setVisibility(View.GONE); 
       user_status = etxt_status.getText().toString(); 
       Bundle params = new Bundle(); 
       params.putString("caption", etxt_status.getText().toString()); 
       params.putString("place", user_loc_id); 
       params.putString("tags", ids); 
       params.putByteArray("picture", bitmapdata); 

       new GraphRequest(
         AccessToken.getCurrentAccessToken(), 
         "/" + user_fb_id + "/photos", 
         params, 
         HttpMethod.POST, 
         new GraphRequest.Callback() { 
          public void onCompleted(GraphResponse response) { 
           //new getPlaceId().execute(); 
           JSONObject o = response.getJSONObject(); 
           try { 
            user_status_id = o.getString("id"); 
           } catch (Exception ex) { 

           } finally { 
            new insertCheckinDetails().execute(); 
           } 
           Toast.makeText(FacebookStatusUpdate.this, "Status Updated", Toast.LENGTH_SHORT).show(); 
          } 
         } 
       ).executeAsync(); 
      } 
     } 
    }); 
    url_paging = new ArrayList<>(); 
    friends = new ArrayList<>(); 
    fb_name = new ArrayList<>(); 
    fb_id = new ArrayList<>(); 
    fb_images = new ArrayList<>(); 
    ls_json_obj = new ArrayList<>(); 
    new abc().execute(); 
} 

使用此链接Graph API Photo但不工作。

回答

0

您的代码工作正常,无需朋友标记即可在Facebook上上传图片,为您的图片标注好友,您必须进行以下更改。更换

for (String s : user_friends_id) { 
    ids += s + ","; 
} 

params.putString("tags", ids); 

随着

String tagFriendListId=""; 
for(int i=0;i<user_friends_id.size();i++) 
{ 
    tagFriendListId = tagFriendListId+"   {'tag_uid':'"+user_friends_id.get(i)+"'} ,"; 
} 
tagFriendListId=tagFriendListId.substring(0,  tagFriendListId.length()-1); 

params.putString("tags","["+tagFriendListId+"]");