FBSDKLog:从 Graph API v2.4 开始,对 /me/permissions 的 GET 请求应包含显式的“字段”参数
Posted
技术标签:
【中文标题】FBSDKLog:从 Graph API v2.4 开始,对 /me/permissions 的 GET 请求应包含显式的“字段”参数【英文标题】:FBSDKLog: starting with Graph API v2.4, GET requests for /me/permissions should contain an explicit "fields" parameter 【发布时间】:2015-09-12 14:00:15 【问题描述】:有人知道我为什么会收到这个错误吗?我有一个字段参数集。我是 swift 和编码的新手,任何帮助将不胜感激。
let graphRequest = FBSDKGraphRequest(graphpath: "me", parameters: ["fields": "id, name, gender"])
// start the request:
graphRequest.startWithCompletionHandler(
// void in means that it will return nothing upon completion
(connection, result, error) -> Void in
// do an error check
if error != nil
print(error)
else if let result = result
PFUser.currentUser()?["gender"] = result["gender"]
PFUser.currentUser()?["name"] = result["name"]
PFUser.currentUser()?.save()
// use the user's FB id to get their public profile. First make their id a string:
let userId = result["id"] as! String
// next go to the internet and get their photo from FB:
let facebookProfilePictureUrl = "https://graph.facebook.com/" + userId + "/picture?type=large"
【问题讨论】:
【参考方案1】:有一种方法可以让你得到对象“我”,然后你可以获取它的每一个值
let graphRequest : FBSDKGraphRequest = FBSDKGraphRequest(graphPath: "me", parameters: nil)
graphRequest.startWithCompletionHandler( (connection, result, error) -> Void in
if (error) != nil
NSLog("Error: \(error)")
ActivityIndicatorWithLabel.shared.hideProgressView()
view.makeToast(message: "We are unable to connect to Facebook. Please try after sometime")
else
self.facebookData(result)
)
在这个结果中,我们得到了用户的所有详细信息 这是一种从中获取的方法
func facebookData(result: AnyObject)
NSLog("Sending Login from facebook call")
var missingFields:[String] = []
userSocialDetailsGlobal.loginType = "facebook"
userSocialDetailsGlobal.socialId = result.valueForKey("id") as! String
userSocialDetailsGlobal.firstName = result.valueForKey("first_name") as! String
userSocialDetailsGlobal.lastName = result.valueForKey("last_name") as! String
userSocialDetailsGlobal.socialToken = FBSDKAccessToken.currentAccessToken().tokenString
struct userSocialDetailsGlobal
static var socialId: String = String()
static var firstName: String = String()
static var lastName: String = String()
static var loginType: String = String()
static var socialToken: String = String()
【讨论】:
请指定userSocialDetails全局变量以上是关于FBSDKLog:从 Graph API v2.4 开始,对 /me/permissions 的 GET 请求应包含显式的“字段”参数的主要内容,如果未能解决你的问题,请参考以下文章
Facebook Graph API v2.4 不返回扩展用户数据
Facebook Graph API Group Feed没有显示v2.3之后的帖子
Facebook JS SDK 的 FB.api('/me') 方法不返回我在 Graph API v2.4+ 中期望的字段