本文介绍了获取朋友列表facebook 3.0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我正在使用新的SDK(3.0)从Facebook获取我的朋友列表。我正面临着什么样的参数需要插入Bundle以及如何使用newMyFriendRequest和GraphAPI的问题。I'm trying to obtain my friend list from facebook using new SDK(3.0). I'm facing problems related to what kind of params I need to insert in a Bundle and how to use newMyFriendRequest and GraphAPI.我没有在Facebook文档中找到关于我们必须使用什么样的领域。根据 GraphExplorer ,我在我的软件包中插入了这个字符串id,name ,朋友作为价值。下面的代码显示了我现在在做什么。我收到我的照片和名字后,我执行newMyFriendRequest。我相信它默认使用GraphAPI。I didn't find on facebook documentation a place about what kind of field does we have to use. Based on GraphExplorer I insert in my Bundle the key "fields" with this string "id,name,friend" as a value. The code below shows what I'm doing right now. After I get My picture and name I execute newMyFriendRequest. I believe it uses GraphAPI by default.我在StackOverflow上看到一些帖子相关:I've seen here on StackOverflow some posts related: 如何使用新的Android SDK发送FQL查询 Facebook Android SDK请求参数:where find documentation?它有助于我,我不想使用FQL。对于响应II'm接收这个JSON,就像一个答案:It helps me little and I don't want to use FQL. For response II'm receiving this JSON like an answer:{Response: responseCode: 500, graphObject: null, error: {HttpStatus: 500, errorCode: 100, errorType: FacebookApiException, errorMessage: Unsupported operation}, isFromCache:false}注意事项我在Android SDK的Facebook SDK中非常新。Notice I'm very new in Facebook SDK for Android.private void onSessionStateChange(final Session session, SessionState sessionState, Exception ex){ if(session != null && session.isOpened()){ getUserData(session); }}private void getUserData(final Session session){ Request request = Request.newMeRequest(session, new Request.GraphUserCallback() { @Override public void onCompleted(GraphUser user, Response response) { if(user != null && session == Session.getActiveSession()){ pictureView.setProfileId(user.getId()); userName.setText(user.getName()); getFriends(); } if(response.getError() !=null){ } } }); request.executeAsync();}private void getFriends(){ Session activeSession = Session.getActiveSession(); if(activeSession.getState().isOpened()){ Request friendRequest = Request.newMyFriendsRequest(activeSession, new GraphUserListCallback(){ @Override public void onCompleted(List<GraphUser> users, Response response) { Log.i("INFO", response.toString()); } }); Bundle params = new Bundle(); params.putString("fields", "id,name,friends"); friendRequest.setParameters(params); friendRequest.executeAsync(); }}推荐答案 getFriends()方法,更改此行:In getFriends() method, change this line:params.putString("fields", "id,name,friends"); byparams.putString("fields", "id, name, picture"); 这篇关于获取朋友列表facebook 3.0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-22 12:20