Php 解析facebook图形api响应部分正常

Php 解析facebook图形api响应部分正常,php,json,facebook,facebook-graph-api,Php,Json,Facebook,Facebook Graph Api,我一直在尝试解析来自Facebook graph API的响应,部分工作正常 响应返回以下内容: Facebook\GraphObject Object ( [backingData:protected] => Array ( [0] => stdClass Object ( [id] => 448835061804426_813332478688014

我一直在尝试解析来自Facebook graph API的响应,部分工作正常

响应返回以下内容:

Facebook\GraphObject Object
(
    [backingData:protected] => Array
        (
            [0] => stdClass Object
                (
                    [id] => 448835061804426_813332478688014
                    [from] => stdClass Object
                        (
                            [category] => Software
                            [name] => Gibbo 2D - Game Engine
                            [id] => 448835061804426
                        )

                    [story] => Gibbo 2D - Game Engine likes a link.
                    [story_tags] => stdClass Object
                        (
                            [0] => Array
                                (
                                    [0] => stdClass Object
                                        (
                                            [id] => 448835061804426
                                            [name] => Gibbo 2D - Game Engine
                                            [offset] => 0
                                            [length] => 22
                                            [type] => page
                                        )

                                )

                        )

                    [privacy] => stdClass Object
                        (
                            [value] => 
                        )

                    [type] => status
                    [created_time] => 2014-10-31T11:10:49+0000
                    [updated_time] => 2014-10-31T11:10:49+0000
                )

            [1] => stdClass Object
                (
                    [id] => 448835061804426_809773115710617
                    [from] => stdClass Object
                        (
                            [category] => Software
                            [name] => Gibbo 2D - Game Engine
                            [id] => 448835061804426
                        )

                    [message] => We're currently facing some server issues, hence the website being down, but we'll try to figure out the problem as soon as possible. 

Sorry for any inconvenience and thanks for your understanding :)
                    [privacy] => stdClass Object
                        (
                            [value] => 
                        )

                    [type] => status
                    [status_type] => mobile_status_update
                    [created_time] => 2014-10-24T15:23:39+0000
                    [updated_time] => 2014-10-24T15:23:39+0000
                    [shares] => stdClass Object
                        (
                            [count] => 1
                        )

                )
(...)
$content = $response->getGraphObject();
$pagefeed = $content->getProperty('data')->asArray();
foreach($pagefeed as $post) {
    echo $post->message;
}
假设我想循环浏览每一篇文章并检索字段消息。我尝试了以下方法:

Facebook\GraphObject Object
(
    [backingData:protected] => Array
        (
            [0] => stdClass Object
                (
                    [id] => 448835061804426_813332478688014
                    [from] => stdClass Object
                        (
                            [category] => Software
                            [name] => Gibbo 2D - Game Engine
                            [id] => 448835061804426
                        )

                    [story] => Gibbo 2D - Game Engine likes a link.
                    [story_tags] => stdClass Object
                        (
                            [0] => Array
                                (
                                    [0] => stdClass Object
                                        (
                                            [id] => 448835061804426
                                            [name] => Gibbo 2D - Game Engine
                                            [offset] => 0
                                            [length] => 22
                                            [type] => page
                                        )

                                )

                        )

                    [privacy] => stdClass Object
                        (
                            [value] => 
                        )

                    [type] => status
                    [created_time] => 2014-10-31T11:10:49+0000
                    [updated_time] => 2014-10-31T11:10:49+0000
                )

            [1] => stdClass Object
                (
                    [id] => 448835061804426_809773115710617
                    [from] => stdClass Object
                        (
                            [category] => Software
                            [name] => Gibbo 2D - Game Engine
                            [id] => 448835061804426
                        )

                    [message] => We're currently facing some server issues, hence the website being down, but we'll try to figure out the problem as soon as possible. 

Sorry for any inconvenience and thanks for your understanding :)
                    [privacy] => stdClass Object
                        (
                            [value] => 
                        )

                    [type] => status
                    [status_type] => mobile_status_update
                    [created_time] => 2014-10-24T15:23:39+0000
                    [updated_time] => 2014-10-24T15:23:39+0000
                    [shares] => stdClass Object
                        (
                            [count] => 1
                        )

                )
(...)
$content = $response->getGraphObject();
$pagefeed = $content->getProperty('data')->asArray();
foreach($pagefeed as $post) {
    echo $post->message;
}
它显示了每条消息的内容,但也引发了一个错误: 未定义的属性:stdClass::$message

我相信我应该使用getProperty,但它没有这样显示任何东西

编辑

在foreach内部,我应该使用isset


谢谢

您调试了$pagefeed吗?调试是什么意思?就像我说的,每一条信息都被打印在屏幕上,但也有我提到的错误。打印的每封邮件都有上面的错误。我在主postAh damn中添加了一个屏幕截图链接,问题是检索到的数据中有一些元素没有message属性。也就是说,我只需要检查它是否设置了。谢谢