2016-08-15 87 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+"]");