![](/img/trans.png)
[英]How to execute graph-api Facebook Android SDK to upload photo and tag people?
[英]Graph API photo upload with friend tag
我想要的是从android应用程序发布状态,该状态包含图像,其中有些人被标记在其中。 当我仅用标签或仅用照片标记的人发布状态时,它的运行情况就很好。 当我添加带有标签的照片并将其发布到fb时,问题来了,我的个人资料什么也没有显示。
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,但不起作用。
您的代码可以很好地将没有朋友标签的图像上传到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+"]");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.