1

I was searching around to find answer to my question but I couldn't.

Can anyone tell me or at least guide me that How can I Tag friends to photo which I am gonna upload(post) to Facebook. Searching around I know that this is possible but I can't find the way how can I do it.

Can anyone guide me? I have seen in many apps this option of tagging friends so I know this is possible and someone knows the answer to that. Please share with me. I will be thankful to him/her.

4

1 回答 1

1

请参阅此处的照片 API 参考:https ://developers.facebook.com/docs/reference/api/photo/#tags

从文档中,您可以通过几种不同的方式进行操作,我在下面向您展示了几种。假设您有要标记的照片的 PHOTO_ID,第一种方法标记单个用户,并给出他们脸部位置的 (x,y)。请注意,(x,y)不是照片中的精确坐标,而是百分比。

Bundle params = new Bundle();
params.putString("to", "USER_ID");
params.putInt("x", 25);
params.putInt("y", 25);
Request tagRequest = new Request(session, "PHOTO_ID/tags", params, HttpMethod.POST, new Request.Callback() {
    public void onCompleted(Response response) {
        // Do something here
    }
});
tagRequest.executeAsync();

或者你可以像这样一次标记很多人(你也可以构造一个 JSON 对象,然后将 toString 传递给“tags”参数)。

Bundle params = new Bundle();
params.putString("tags", "[{\"tag_uid\": \"USER_ID_1\"},{\"tag_uid\": \"USER_ID_2\"}]");
Request tagRequest = new Request(session, "PHOTO_ID/tags", params, HttpMethod.POST, new Request.Callback() {
    public void onCompleted(Response response) {
        // Do something here
    }
});
tagRequest.executeAsync();

请注意,我没有测试上面的代码,因此您应该仅将其用作指南。

于 2013-03-01T18:14:32.487 回答