它显示了正在使用该应用的朋友数量,但是,当我使用“/ app / scores”获取我朋友的分数时,它只返回其中的2个。
以下是获取我朋友的代码:
func getFriends() {
FBRequestConnection.startWithGraphPath("/me/friends", parameters: nil, HTTPMethod: "GET", completionHandler: {(connect: FBRequestConnection!, result: AnyObject!, error: NSError!) -> Void in
var dict = result as NSDictionary
println("Dict: \(dict)")
})
}
输出结果如下:
Dict: {
data = (
{
id = 10204187717756755;
name = "Hardeep Singh";
},
{
id = 629290707196986;
name = "Ishy Singh";
},
{
id = 1572289319655654;
name = "Ashlee Carter";
}
);
然后为了得到我朋友的分数,我正在使用这段代码:
FBRequestConnection.startWithGraphPath("/app/scores", parameters: nil, HTTPMethod: "GET", completionHandler: {(connection: FBRequestConnection!, result: AnyObject!, error: NSError!) -> Void in
var resultdict = result as NSDictionary!
let userDefaults = NSUserDefaults.standardUserDefaults()
var data: NSArray! = resultdict.objectForKey("data") as NSArray!
var int = data.count as Int
println("Dict: \(resultdict)")
//println("Int: \(int)")
for (var i = 0; i < int; i++) {
let packet: NSMutableDictionary = data.objectAtIndex(i) as NSMutableDictionary
let score = packet.objectForKey("score") as Int
var scoreStr = String(score)
self.scoreArray.addObject(score)
let user: NSMutableDictionary = packet.objectForKey("user") as NSMutableDictionary
let name = user.objectForKey("name") as String
if (self.name == name) {
let highScore = score
userDefaults.setValue(highScore, forKey: "fbHighScore")
}
self.nameArray.addObject(name)
self.globalDict.setValue(scoreStr, forKey: name)
}
userDefaults.setValue(self.nameArray, forKey: "nameArray")
userDefaults.setValue(self.scoreArray, forKey: "scoreArray")
userDefaults.setValue(self.globalDict, forKey: "dict")
println("Scores: \(self.globalDict)")
})
产生此输出:
Scores: {
"Ishy Singh" = 20;
"Sunny Singh" = 6;
}
所以,我不知道我是如何从有3个朋友使用该应用程序,只得到我的分数和其他1分。我已经跟踪了每一个Facebook文档,并搜索了我能想到的所有内容,但没有运气。有什么建议吗?
答案 0 :(得分:3)
我找到了答案。没有展示的用户拥有“只有我”的隐私。对于应用发布设置,当我将设置更改为“朋友”时,它就有用了。