如何解析一个Facebook图表api的回应 [英] How to parse a facebook graph api response
本文介绍了如何解析一个Facebook图表api的回应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Facebook \GraphObject Object
(
[backingData:protected] => Array
(
[data] => Array
(
[0] => stdClass Object
[id] => 111
[from] => stdClass对象
(
[id] => 111
[name] => fo bar
)
[name] => etc
)
我试图执行 $ reponse-> {'backingData:protected'}
,但不起作用。 >
另外下一组结果是一个链接到图api但是resul这是纯粹的json。
[paging] => stdClass Object
(
[cursors] => stdClass对象
(
[after] => MTI3NzMzMTQwMzYy
[before] => MTAxNTQzNjI5NTY1NDAzNjM =
)
[next] => https://graph.facebook.com/v2.0/111/albums?access_token=xxxxv&limit=25&after=yyy
)
我的代码
code> $ user_profile =(new FacebookRequest(
$ session,'GET','/ me / albums'
)) - > execute() - > getGraphObject();
echo'< pre>';的print_r($ user_profile); echo'< / pre>';
解决方案
这里是:
$ user_profile =(new FacebookRequest(
$ session,'GET','/ me / albums'
)) - > ;执行() - > getGraphObject();
$ album = $ user_profile-> getProperty('data');
$ album_data = $ album-> asArray(); //这将为你做所有的工作..
foreach($ album_data as $ row){
var_dump $行);
}
I have a facebook graph api request which brings back this response
Facebook\GraphObject Object
(
[backingData:protected] => Array
(
[data] => Array
(
[0] => stdClass Object
(
[id] => 111
[from] => stdClass Object
(
[id] => 111
[name] => fo bar
)
[name] => etc
)
I've tried to do $reponse->{'backingData:protected'}
but it doesn't work.
Also the next set of results is a link to the graph api but the results from this is pure json.
[paging] => stdClass Object
(
[cursors] => stdClass Object
(
[after] => MTI3NzMzMTQwMzYy
[before] => MTAxNTQzNjI5NTY1NDAzNjM=
)
[next] => https://graph.facebook.com/v2.0/111/albums?access_token=xxxxv&limit=25&after=yyy
)
My code
$user_profile = (new FacebookRequest(
$session, 'GET', '/me/albums'
))->execute()->getGraphObject();
echo '<pre>'; print_r($user_profile); echo '</pre>';
解决方案
Here is the way:
$user_profile = (new FacebookRequest(
$session, 'GET', '/me/albums'
))->execute()->getGraphObject();
$album = $user_profile->getProperty('data');
$album_data = $album->asArray();//this will do all job for you..
foreach($album_data as $row){
var_dump($row);
}
这篇关于如何解析一个Facebook图表api的回应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文