这是我的代码。帮助我从我的Facebook帐户获取工作和提供详细信息。我做错了吗?
if result.token != nil {
let profileReq = FBSDKGraphRequest(graphPath: "me", parameters: ["fields": "email, first_name,last_name,id,work,education"])
let connection = FBSDKGraphRequestConnection()
connection.addRequest(profileReq, completionHandler: { (connection, result, error) -> Void in
if error == nil {
print("Graph Request Result: \(result)")
if let email = result.valueForKey("email") as? String {
//名字
let first_name = result.valueForKey("first_name") as! String
//姓氏
let last_name = result.valueForKey("last_name") as! String
//对于ID
let fb_id = result.valueForKey("id") as! String
//对于个人资料图片
let profile_pic = "http://graph.facebook.com/" + fb_id + "/picture?type=large"
//作为数组
的工作细节 let wrkAr = NSMutableArray()
if let workAr = result.objectForKey("work") as? NSArray {
for i in 0..<workAr.count {
let obj = workAr.objectAtIndex(i) as! NSDictionary
var name = ""
if let employer = obj.objectForKey("employer") as? NSDictionary {
name = employer.valueForKey("name") as! String
}
var pos = ""
if let position = obj.objectForKey("position") as? NSDictionary {
pos = position.valueForKey("name") as! String
}
name = name + "_" + pos + "_" + "no"
wrkAr.addObject(name)
}
}
//教育详情为数组
let eduAr = NSMutableArray()
if let educationAr = result.objectForKey("education") as? NSArray {
for i in 0..<educationAr.count {
let obj = educationAr.objectAtIndex(i) as! NSDictionary
var name = ""
if let school = obj.objectForKey("school") as? NSDictionary {
name = school.valueForKey("name") as! String
}
name = name + "_"
eduAr.addObject(name)
}
}
答案 0 :(得分:0)