Facebook iOS SDK - get friends list

后端 未结 11 1494
猫巷女王i
猫巷女王i 2020-12-07 12:41

Using the Facebook iOS SDK, how can I get an NSArray of all my friends and send them an invitation to my app? I am specifically looking for the graph path to ge

11条回答
  •  广开言路
    2020-12-07 12:51

    Here is a Swift Version.

    var friendsRequest : FBRequest = FBRequest.requestForMyFriends()
    friendsRequest.startWithCompletionHandler{(connection:FBRequestConnection!, result:AnyObject!, error:NSError!) -> Void in
        let resultdict = result as NSDictionary
        let friends : NSArray = resultdict.objectForKey("data") as NSArray
    
        println("Found: \(friends.count) friends")
        for friend in friends {
            let id = friend.objectForKey("id") as String
            println("I have a friend named \(friend.name) with id " + id)
        }
    }
    

提交回复
热议问题