将face book的提要列表与graph api集成时出现的问题



我想从facebook的特定应用程序中获得提要列表,我目前正在使用图形api,让我展示我的代码以更好地解释

代码::

func PostList(){
var Requset : FBSDKGraphRequest
print("(FBSDKAccessToken.current())")
let acessToken = String(format:"%@", FBSDKAccessToken.current().tokenString) as String
print("(acessToken)")
let parameters1 = ["access_token":FBSDKAccessToken.current().tokenString]

Requset  = FBSDKGraphRequest(graphPath:"me/?fields=feed{message,full_picture,id,application,likes{name,pic_crop},comments{message,from,created_time},created_time}", parameters:parameters1, httpMethod:"GET")
Requset.start(completionHandler: { (connection, result, error) -> Void in
//MBProgressHUD.hideHUDForView(appDelegate.window, animated: true)
if ((error) != nil)
{
print("Error: (error)")
}
else
{
print("fetched user: (result)")
//var dataDict: AnyObject = (result! as AnyObject).object(forKey: "data")!
}
})
}

但从这一点我没有得到响应,但在Graph Api explorer"我/?fields=feed{message,full_picture,id,application,likes{name,pic_crop},comments{message,from,created_time},created_time}"中,我添加了这一行,然后它工作正常,但在集成时我没有得到响应

如果我通过"我/帖子"作为graphPath,那么我得到的回复如下

响应::

{
"data": [
{
"message": "Test Post",
"created_time": "2018-07-12T11:46:58+0000",
"id": "103361910512644_196181887897312"
},
{
"message": "Fgfhjjhh",
"created_time": "2018-07-11T11:26:35+0000",
"id": "103361910512644_195184807997020"
},
{
"message": "Test",
"created_time": "2018-07-11T11:00:57+0000",
"id": "103361910512644_195166977998803"
},
{
"message": "fhchfhgfhfghg",
"created_time": "2018-07-10T05:55:18+0000",
"id": "103361910512644_193906868124814"
},
{
"message": "Test",
"created_time": "2018-07-10T05:11:00+0000",
"id": "103361910512644_193879061460928"
},
{
"created_time": "2018-07-09T11:04:42+0000",
"id": "103361910512644_193122468203254"
},
{
"created_time": "2018-07-09T11:04:13+0000",
"id": "103361910512644_193122148203286"
},
{
"created_time": "2018-07-09T11:03:53+0000",
"id": "103361910512644_193121878203313"
},
{
"created_time": "2018-07-09T11:03:28+0000",
"id": "103361910512644_193121571536677"
},
{
"created_time": "2018-07-06T08:44:58+0000",
"id": "103361910512644_190085968506904"
},
{
"created_time": "2018-07-06T08:44:42+0000",
"id": "103361910512644_190085751840259"
},
{
"message": "Test test ..hfjdhdududhd",
"created_time": "2018-07-03T11:05:28+0000",
"id": "103361910512644_187249475457220"
},
{
"message": "Test Post From Mode Share App.",
"created_time": "2018-07-03T09:46:25+0000",
"id": "103361910512644_187196988795802"
},
{
"message": "Test Post From Web.",
"created_time": "2018-07-02T11:25:33+0000",
"id": "103361910512644_186233918892109"
},
{
"message": "Test Post From App.",
"created_time": "2018-07-02T11:24:43+0000",
"id": "103361910512644_186233275558840"
}
],
"paging": {
"previous": "https://graph.facebook.com/v3.0/103361910512644/posts?format=json&since=1531396018&access_token=EAAC5SyZBtEogBAN9lib8o4ZA9M6ZCGIINBFAJtttfWysfZA5IvMPZAm6XsR9YhMMTLwTb9ScejLgey5gJiPsNsfGL4kk0ObIWdpTtjrJZAvqAmGR82xdTva6dlGeSucJol2WMVvjyjpajvVZCde4HEk6EbFjzczzCmtF31jqnsMrrZBKyZCCJ7ncaNjGhSC4RfMAxNSWyqwBMerdTJyzCpoFZA&limit=25&__paging_token=enc_AdA4E14ICu5l7HjzFFe6w188bKHbs4UPmOwoYRjmEdZBECzR4IYVdR7ZANBAYWlXT9ZCM8MYNaXMPbLLcByDWnZCohogKburL9Ardw9KOLz6Bi61HQZDZD&__previous=1",
"next": "https://graph.facebook.com/v3.0/103361910512644/posts?format=json&access_token=EAAC5SyZBtEogBAN9lib8o4ZA9M6ZCGIINBFAJtttfWysfZA5IvMPZAm6XsR9YhMMTLwTb9ScejLgey5gJiPsNsfGL4kk0ObIWdpTtjrJZAvqAmGR82xdTva6dlGeSucJol2WMVvjyjpajvVZCde4HEk6EbFjzczzCmtF31jqnsMrrZBKyZCCJ7ncaNjGhSC4RfMAxNSWyqwBMerdTJyzCpoFZA&limit=25&until=1530530683&__paging_token=enc_AdDQAFGJpwBvzZAnvmFIdJ4w5mCemiG8rcZCMslwNWjOSwtxqUpA7cZCzAVjJUwZCA2se9tEuOotiSxTDGT6ddnWvfGnRCMxC90ublTHqFZC6F34qrQZDZD"
}
}

但我想计数评论所有数据,但我没有得到回应

有人帮我吗?

试试这个代码

if FBSDKAccessToken.current() != nil{
let graphRequest = FBSDKGraphRequest(graphPath: "/me", parameters: ["fields": "email, name, friends"], httpMethod: "GET")
let connection = FBSDKGraphRequestConnection()
connection.add(graphRequest, completionHandler: { (connection, result, error) -> Void in
if error == nil
{
print(result)
}
})
}

相关内容

  • 没有找到相关文章

最新更新