使用 Parse 时如何获取所有 Facebook 好友的列表?
How to get list of all Facebook Friends when using Parse?
下面是getFBfriends()在viewDidAppear里面的代码中运行时的输出:
输出:
Result Dict: {
data = (
);
summary = {
"total_count" = 711;
};
}
Found 0 friends
"total_count = 711"正确,但没有好友数据。我在这里想念什么?认为权限是正确的。
代码:
class SignUpViewController: UIViewController {
@IBOutlet weak var btn_signIn: UIButton!
@IBAction func action_btnSignIn(sender: AnyObject) {
var permissions = ["public_profile", "user_friends"]
println("in action_btnSignIn() of SignUpViewController")
var fbloginView:FBLoginView = FBLoginView(readPermissions: ["email", "public_profile", "user_friends"])
override func viewDidAppear(animated: Bool) {
if PFUser.currentUser() != nil {
println("User logged in, so launching Menu Screen")
//self.performSegueWithIdentifier("launchmenu", sender: self)
getDBfriends()
} else {
println("User NOT logged in")
}
}
func getDBfriends() {
var friendsRequest: FBRequest = FBRequest.requestForMyFriends()
friendsRequest.startWithCompletionHandler{(connection:FBRequestConnection!, result:AnyObject!, error:NSError!) -> Void in
var resultdict = result as NSDictionary
println("Result Dict: \(resultdict)")
var data : NSArray = resultdict.objectForKey("data") as NSArray
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")
}
}
}
您的权限是正确的,但请尝试使用另一个 fb 帐户登录您的应用程序,您将在数据响应中获得该用户的详细信息。
Graph v2.0后API,您也只能获取授权您App的好友。结果是正确的,none 你的朋友授权你的应用程序所以它是空的,只显示朋友总数。
更多信息:Get ALL User Friends Using Facebook Graph API - Android
下面是getFBfriends()在viewDidAppear里面的代码中运行时的输出:
输出:
Result Dict: {
data = (
);
summary = {
"total_count" = 711;
};
}
Found 0 friends
"total_count = 711"正确,但没有好友数据。我在这里想念什么?认为权限是正确的。
代码:
class SignUpViewController: UIViewController {
@IBOutlet weak var btn_signIn: UIButton!
@IBAction func action_btnSignIn(sender: AnyObject) {
var permissions = ["public_profile", "user_friends"]
println("in action_btnSignIn() of SignUpViewController")
var fbloginView:FBLoginView = FBLoginView(readPermissions: ["email", "public_profile", "user_friends"])
override func viewDidAppear(animated: Bool) {
if PFUser.currentUser() != nil {
println("User logged in, so launching Menu Screen")
//self.performSegueWithIdentifier("launchmenu", sender: self)
getDBfriends()
} else {
println("User NOT logged in")
}
}
func getDBfriends() {
var friendsRequest: FBRequest = FBRequest.requestForMyFriends()
friendsRequest.startWithCompletionHandler{(connection:FBRequestConnection!, result:AnyObject!, error:NSError!) -> Void in
var resultdict = result as NSDictionary
println("Result Dict: \(resultdict)")
var data : NSArray = resultdict.objectForKey("data") as NSArray
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")
}
}
}
您的权限是正确的,但请尝试使用另一个 fb 帐户登录您的应用程序,您将在数据响应中获得该用户的详细信息。
Graph v2.0后API,您也只能获取授权您App的好友。结果是正确的,none 你的朋友授权你的应用程序所以它是空的,只显示朋友总数。
更多信息:Get ALL User Friends Using Facebook Graph API - Android