我正在使用facebook api和PHP通过postID获取对特定帖子的评论
$request = new FacebookRequest(
$sess,
'GET',
'/xxxxxxxxxxxxxxxxxxxxxx/comments'
);
$response = $request->execute();
$graphObject = $response->getGraphObject();
当我使用图形api执行此操作时的结果是
这样的文件{
"data":[
{
"id": "xxxxxxxxxxxxxxxxxxxxx",
"from": {
"id": "yyyyyyyyyyyyy",
"name": "someName"
},
"message": "commentMessage",
"can_remove": true,
"created_time": "2014-12-06T18:05:03+0000",
"like_count": 0,
"user_likes": false
}
],
"paging": {
"cursors": {
"after": "WTI5dGJXVnVkRjlqZFhKemIzSTZNVFUwTURJMU56Z3dPVFUxTkRjME1qb3hOREUzT0RnNU1UQXpPaTB4",
"before": "WTI5dGJXVnVkRjlqZFhKemIzSTZNVFUwTURJMU56Z3dPVFUxTkRjME1qb3hOREUzT0RnNU1UQXpPaTB4"
}
}
}
响应图对象不匹配任何类型的graphObject子类。
我试过了:
$graphObject['data'][0]['from']['name']
但图形对象不是数组
如何从$ graphObject
获取名称或消息等属性答案 0 :(得分:0)
$ object = $ response-> getGraphObject();
//用户示例
echo $ object-> getProperty('name'); echo $ user-> getName();
//位置示例
echo $ object-> getProperty('country'); echo $ loc-> getCountry();
更多:https://developers.facebook.com/docs/php/GraphObject/4.0.0