gpt4 book ai didi

php - 如何解析 facebook graph api 响应

转载 作者:行者123 更新时间:2023-12-02 05:21:57 25 4
gpt4 key购买 nike

我有一个 facebook graph api 请求返回这个响应

Facebook\GraphObject Object
(
[backingData:protected] => Array
(
[data] => Array
(
[0] => stdClass Object
(
[id] => 111
[from] => stdClass Object
(
[id] => 111
[name] => fo bar
)

[name] => etc

)

我已经尝试执行 $reponse->{'backingData:protected'} 但它不起作用。

另外,下一组结果是图形 api 的链接,但结果是纯 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
)

我的代码

    $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'
))->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);
}

关于php - 如何解析 facebook graph api 响应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24897838/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com