我正试图快速获取所有taggable_friends profil图片。使用我的代码,我可以获得我的taggable_friends'这个名字,但我不知道如何获得他们的个人资料......任何想法如何?感谢!!!
var fbRequest = FBSDKGraphRequest(graphPath:"/me/taggable_friends", parameters: nil);
fbRequest.startWithCompletionHandler { (connection : FBSDKGraphRequestConnection!, result : AnyObject!, error : NSError!) -> Void in
if error == nil {
var resultdict = result as! NSDictionary
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
let name = valueDict.objectForKey("name") as! String
// let url = valueDict.objectForKey("url") as! String -- is not working
我已经看到了这个主题:How can I retrieve friend's picture through FBRequest in swift但我仍然不知道如何做到这一点......
答案 0 :(得分:1)
不确定这是否是最有效的方法,但代码有效:
func returnUserData()
{
let graphRequest : FBSDKGraphRequest = FBSDKGraphRequest(graphPath: "me/taggable_friends?", parameters: nil)
graphRequest.startWithCompletionHandler({ (connection, result, error) -> Void in
if ((error) != nil)
{
// Process error
println("Error: \(error)")
}
else
{
println("fetched user: \(result)")
var resultdict = result as! NSDictionary
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
let name = valueDict.objectForKey("name") as! String
let pictureDict = valueDict.objectForKey("picture") as! NSDictionary
let pictureData = pictureDict.objectForKey("data") as! NSDictionary
let pictureURL = pictureData.objectForKey("url") as! String
println("Name: \(name) URL: \(pictureURL)")
}
}
})
}
答案 1 :(得分:0)
看看
请求应该是这样的
graphPath:"/me/taggable_friends?fields=id,name,picture"