gpt4 book ai didi

android - 无法在 facebook sdk 示例中获取好友列表的所有字段,而在好友选择器示例中仅获取 id、android 中的名称

转载 作者:行者123 更新时间:2023-11-29 00:24:33 24 4
gpt4 key购买 nike

我正在开发用于获取登录用户的所有好友列表的 facebok 示例演示。我正在成功运行 Friend Picker Sample,但无法提取 friend 的所有详细信息,如电子邮件、名字、姓氏等。我只得到 ID、姓名。

如果有人有想法请回复。

这是我的代码:-

public void getFriends(Properties properties, final OnFriendsRequestListener onFriendsRequestListener)
{
// if we are logged in
if (isLogin())
{
// move these params to method call parameters
Session session = getOpenSession();
Bundle bundle = null;
if (properties != null)
{
bundle = properties.getBundle();

}
Request request = new Request(session, "me/friends", bundle, HttpMethod.GET, new Request.Callback()
{
@Override
public void onCompleted(Response response)
{
List<GraphUser> graphUsers = typedListFromResponse(response, GraphUser.class);

FacebookRequestError error = response.getError();
if (error != null)
{
// log
logError("failed to get friends", error.getException());

// callback with 'exception'
if (onFriendsRequestListener != null)
{
onFriendsRequestListener.onException(error.getException());
}
}
else
{
// callback with 'complete'
if (onFriendsRequestListener != null)
{
List<Profile> friends = new ArrayList<Profile>(graphUsers.size());
for (GraphUser graphUser: graphUsers)
{

friends.add(Profile.create(graphUser));
}
onFriendsRequestListener.onComplete(friends);
}
}

}
});

RequestAsyncTask task = new RequestAsyncTask(request);
task.execute();

// callback with 'thinking'
if (onFriendsRequestListener != null)
{
onFriendsRequestListener.onThinking();
}
}
else
{
String reason = Errors.getError(ErrorMsg.LOGIN);
logError(reason, null);

// callback with 'fail' due to not being loged
if (onFriendsRequestListener != null)
{
onFriendsRequestListener.onFail(reason);
}
}
}

提前致谢...

最佳答案

经过一番挣扎,我尝试了一些方法,终于找到了解决办法。

public void getFriendsList() {
Bundle bundle=new Bundle();
bundle.putString("fields","id,name,first_name,last_name,email,picture,gender,birthday,work");
mAsyncRunner.request("me/friends",bundle,friendsRequsetListener,null);

}


RequestListener friendsRequsetListener =new RequestListener() {

@Override
public void onMalformedURLException(MalformedURLException e, Object state) {
// TODO Auto-generated method stub

}

@Override
public void onIOException(IOException e, Object state) {
// TODO Auto-generated method stub

}

@Override
public void onFileNotFoundException(FileNotFoundException e, Object state) {
// TODO Auto-generated method stub

}

@Override
public void onFacebookError(FacebookError e, Object state) {
// TODO Auto-generated method stub

}

@Override
public void onComplete(String response, Object state) {
// TODO Auto-generated method stub
String json = response;
try {
Log.e("Response","========>"+json);

}
catch(Exception e){

}
}
};

我希望这对其他人有帮助。谢谢!!

关于android - 无法在 facebook sdk 示例中获取好友列表的所有字段,而在好友选择器示例中仅获取 id、android 中的名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20703238/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com