Facebook Graph API 不返回每个朋友的分数
Posted
技术标签:
【中文标题】Facebook Graph API 不返回每个朋友的分数【英文标题】:Facebook Graph API not returning every friend's score 【发布时间】:2015-02-01 23:58:29 【问题描述】:它显示了正在使用该应用程序的朋友的正确数量,但是,当我使用“/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 文档,并且几乎所有我能想到的都在谷歌上搜索,但没有运气。有什么建议吗?
【问题讨论】:
【参考方案1】:我找到了答案。未显示的用户在应用发布设置中具有“仅限我”的隐私,当我将设置更改为“朋友”时,它起作用了。
【讨论】:
以上是关于Facebook Graph API 不返回每个朋友的分数的主要内容,如果未能解决你的问题,请参考以下文章