gpt4 book ai didi

ios - 如何显示来自 graph api 的 user_friends 数据?

转载 作者:搜寻专家 更新时间:2023-11-01 06:46:17 24 4
gpt4 key购买 nike

我正在 iOs 上制作一个应用程序,我允许用户使用 facebook 登录。我已经在模拟器上测试了我的应用程序,使用 2 个已经成为好友的帐户登录 facebook。但是当我在 https://developers.facebook.com/tools/explorer/145634995501895/ 上测试我的图形路径时。它什么也没显示。

{
"id": "1001399423222952",
"name": "Ega Setya Putra",
"friends": {
"data": [
],
"summary": {
"total_count": 1290
}
}
}

这里是我在 xcode 上的代码,它再次显示为 nil

func getDBfriends() {
let friendsRequest: FBSDKGraphRequest = FBSDKGraphRequest(graphPath: "me?fields=id,name,friends", parameters: nil)
friendsRequest.startWithCompletionHandler{(connection, result: AnyObject!, error) -> Void in
if let resultdict = result as? NSDictionary{
println("Result Dict: \(resultdict)")
var jos = resultdict.objectForKey("data") as! NSArray
var data : NSArray = jos

for i in 0..<data.count {
let valueDict : NSDictionary = data[i] as! NSDictionary
let id = valueDict.objectForKey("id")as! String
println("the id value is \(id)")
}

var friends = resultdict.objectForKey("data") as! NSArray
println("Found \(friends.count) friends")
}
}
}

最佳答案

我认为你的图表路径是错误的。我在 Objective-c 中使用以下路径并让我所有正在使用该应用程序的 friend 。让我知道这是否可以帮助你。

NSData * dataFriendsList = [NSData dataWithContentsOfURL:[NSURL URLWithString:[NSString stringWithFormat:@"https://graph.facebook.com/me/friends?access_token=%@&fields=id,first_name,picture,last_name,name,birthday,gender,location,link,hometown,email,work,education,bio",fbAccessToken]]];

而且您必须获得 Facebook 的 user_friends 许可。

关于ios - 如何显示来自 graph api 的 user_friends 数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30364843/

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