得到Json参数

时间:2017-04-17 06:43:17

标签: json facebook foreach

我需要下面json-string的消息部分。这应该是可能的,但事实并非如此。

echo $ fb_response ['data'] [0] ['message'];

[VGardena] => stdClass Object
    (
        [data] => Array
            (
                [0] => stdClass Object
                    (
                        [message] => The traditional cuisine of Val Gardena - so much variety, so many different local specialities!nCome and visit us this summer at the Dolomites Market in Selva: goo.gl/6kMvsE
                        [story] => Val Gardena Gru00f6den added 3 new photos u2014 eating Strudel in Selva Wolkenstein.
                        [created_time] => 2017-04-16T17:11:00+0000
                        [id] => 105061549531699_1321349021236273
                    )

                [1] => stdClass Object
                    (
                        [message] => ud83cudf37ud83cudf37ud83cudf37 Mbincion a duc na Bona Pasca! ud83cudf37ud83cudf37ud83cudf37nnu25ba Serena #Pasqua a tutti!nu25ba Wir wu00fcnschen euch allen Frohe #Ostern!nu25ba Wishing you a Happy Easter!
                        [story] => Val Gardena Gru00f6den celebrating Easter with Marina Demetz at Val Gardena Gru00f6den.
                        [created_time] => 2017-04-16T08:00:00+0000
                        [id] => 105061549531699_1328683843836124
                    )

            )

        [paging] => stdClass Object
            (
                [previous] => https://graph.facebook.com/v2.8/105061549531699/posts?limit=2&since=1492362660&access_token=EAACx6A6Hb9cBAB8tomDGj9N1FpE2xcWMVE7ad0Y2q08XUjVmGXsQ2aPCEKbX0iiRxK6M6FWYl1os3I2k5ZC1uY2cnJ1bZB2He3KTOpbwNo9KAZAzweShCUFvOt9Nfb2jZB8gHZCiO8l66dxsqdMCAbgxIlkTqJ8EZD&__paging_token=enc_AdCelydXbqb60yLCpaRWbTgLMBNNGGsZAfGqMO82Go1ZCA3ZAkSH6IS2TOBzqBSZA6SXXmltAcOE6ugchoDN3xGK1egG7qp8QtzqYD5u6YLeh9jBZAgZDZD&__previous=1
                [next] => https://graph.facebook.com/v2.8/105061549531699/posts?limit=2&access_token=EAACx6A6Hb9cBAB8tomDGj9N1FpE2xcWMVE7ad0Y2q08XUjVmGXsQ2aPCEKbX0iiRxK6M6FWYl1os3I2k5ZC1uY2cnJ1bZB2He3KTOpbwNo9KAZAzweShCUFvOt9Nfb2jZB8gHZCiO8l66dxsqdMCAbgxIlkTqJ8EZD&until=1492329600&__paging_token=enc_AdBOpmW5OIQydpreytQ0eoWAdD9grbpMpB3XrkTTJL493qrDlacQCGVrn23ZBdZCKqgLxijwuQEnq5E1mwFaeiG2jRqdBvJmN2c7qu5UJQvIDnZBwZDZD
            )

    )

1 个答案:

答案 0 :(得分:0)

  

这应该是可能的,但事实并非如此。

不,不应该,因为data内有对象,而不是数组。 (data本身也是对象的属性。)

通过PHP中的->访问对象属性。

$foo['VGardena']->data[0]->message