它显示了使用该应用程序的朋友的正确数量,但是,当我使用“/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文档,搜索了几乎所有我能想到的东西,但没有运气。有什么建议吗?

最佳答案

我找到了答案。未显示的用户在应用程序发布设置中拥有“只有我”的隐私,当我将设置更改为“朋友”时,它起作用。

关于facebook - Facebook Graph API不会返回每个 friend 的分数,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/28269397/

10-09 09:50