[英]Get friend interests using android facebook SDK
In my app my intention is to get some interests of a friend like music, books, tv. 在我的应用程序中,我的意图是吸引朋友的一些兴趣,例如音乐,书籍和电视。 This information is public.
此信息是公开的。 For this I think I don't need to send a permission.
为此,我认为不需要发送许可。 Based on facebook (poor)documentation, mainly this links: Field Expansion to get friend interest I only need to pass friend ID in the expanded friends field.
基于facebook(较差)的文档,主要是以下链接: 扩展字段以引起朋友兴趣我只需要在扩展的朋友字段中传递朋友ID。 Doing some tests on GraphExplorer I see it creates the following query to get movies form some friend:
我在GraphExplorer上进行了一些测试,我看到它创建了以下查询以从某些朋友那里获取电影:
MY_ID?fields=friends.uid(FRIEND_ID).fields(movies)
I use this and execute execute this code on a Request.newMyFriendRequest asynchronously: 我使用它并在Request.newMyFriendRequest上异步执行以下代码:
Session activeSession = Session.getActiveSession();
if(activeSession.getState().isOpened()){
Request request = Request.newMyFriendsRequest(activeSession,
new GraphUserListCallback(){
@Override
public void onCompleted(List<GraphUser> users, Response response){
GraphUser user = users.get(0);
JSONObject friendLikes = user.getInnerJSONObject();
try {
JSONArray data = friendLikes.getJSONObject("friends").getJSONArray("data");
Log.i("JSON", friendLikes.toString());
addInterests(data, 0);
} catch (JSONException e) {
e.printStackTrace();
}
}
});
Bundle bundle = new Bundle();
bundle.putString("fields", "friends.uid("+friendID+").fields(movies)");
request.setParameters(bundle);
request.executeAsync();
All times I execute this code I receive the following error from JSON: W/System.err(694): org.json.JSONException: No value for friends. 我每次执行此代码时,都会从JSON收到以下错误:W / System.err(694):org.json.JSONException:朋友没有值。 If this isn't the way to get friend interests using GraphAPI, what do I need to do to get these values?
如果这不是使用GraphAPI吸引朋友兴趣的方法,我该怎么做才能获取这些值?
[EDIT] Solved posting friends_likes permission on Login. [EDIT]解决了登录时发布friends_likes权限的问题。 Permission is not sended inside Request.
权限未在Request中发送。 I modified a bit my solution.
我修改了我的解决方案。 If anyone is interested:
如果有人感兴趣:
String fqlQuery = "SELECT music, books, movies FROM user where uid ="+friendID;
Bundle bundle = new Bundle();
bundle.putString("q", fqlQuery);
Request request = new Request(activeSession, "/fql", bundle, HttpMethod.GET,
new Request.Callback() {
@Override
public void onCompleted(Response response) {
// TODO Auto-generated method stub
Log.i("INFO", response.toString());
}
});
Request.executeBatchAsync(request);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.