2016-05-26 3 views
0
$data = file_get_contents("https://graph.facebook.com/246179452202174/posts?access_token=TOKEN"); 
$data = json_decode($data, true); 

print_r(array_values($data)); 

Это мой код. Это просто. Я вижу данные, и когда я посещаю ссылку, она дает мне ту же информацию. Так что это прекрасно. Внизу есть некоторые выходы из api.PHP get facebook posts

Array ([0] => Array ([0] => Array ([id] => 246179452202174_685970631556385 [from] => Array ([name] => LGB eSports [category] => Sports Team [id] => 246179452202174) [message] => We are back! Sorry that we have been silent! But the silence is over! We will soon update you with some breaking news, stay tuned! Do not move your eyes! You do not want to miss this... [privacy] => Array ([value] => [description] => [friends] => [allow] => [deny] =>) [type] => status [status_type] => mobile_status_update [created_time] => 2016-05-26T13:12:23+0000 [updated_time] => 2016-05-26T13:12:23+0000 [is_hidden] => [is_expired] => [likes] => Array ([data] => Array ([0] => Array ([id] => 1042109789201130 [name] => Fabio Broggi) [1] => Array ([id] => 713442998796859 [name] => Christian Bråten) [2] => Array ([id] => 1801480580073327 [name] => Paulo Henrique) [3] => Array ([id] => 971217726332439 [name] => Benjamin Holm Davidsen)) [paging] => Array ([cursors] => Array ([before] => MTA0MjEwOTc4OTIwMTEzMAZDZD [after] => OTcxMjE3NzI2MzMyNDM5)))) 

Когда я пытаюсь повторить $data или, может быть, $data[1] или что-то вроде этого, это не будет работать. Также удаление array_values дает мне вывод «Array» или «ArrayArray».

Итак, как я могу распечатать данные из api? Это тоже не работает; как я могу получить изображение? Я бы хотел напечатать заголовок сообщения и изображение. В качестве ссылки для фида на моем сайте.

Больше код ответа на ссылку:

Array ([data] => Array ([0] => Array ([id] => 246179452202174_685970631556385 [from] => Array ([name] => LGB eSports [category] => Sports Team [id] => 246179452202174) [message] => We are back! Sorry that we have been silent! But the silence is over! We will soon update you with some breaking news, stay tuned! Do not move your eyes! You do not want to miss this... [privacy] => Array ([value] => [description] => [friends] => [allow] => [deny] =>) [type] => status [status_type] => mobile_status_update [created_time] => 2016-05-26T13:12:23+0000 [updated_time] => 2016-05-26T13:12:23+0000 [is_hidden] => [is_expired] => [likes] => Array ([data] => Array ([0] => Array ([id] => 1042109789201130 [name] => Fabio Broggi) [1] => Array ([id] => 713442998796859 [name] => Christian Bråten) [2] => Array ([id] => 1801480580073327 [name] => Paulo Henrique) [3] => Array ([id] => 971217726332439 [name] => Benjamin Holm Davidsen)) [paging] => Array ([cursors] => Array ([before] => MTA0MjEwOTc4OTIwMTEzMAZDZD [after] => OTcxMjE3NzI2MzMyNDM5)))) [1] => Array ([id] => 246179452202174_680011585485623 [from] => Array ([name] => Yoyo xno [category] => Musician/Band [id] => 281466768681242) [to] => Array ([data] => Array ([0] => Array ([name] => LGB eSports [category] => Sports Team [id] => 246179452202174))) [message] => GG - Spotify: https://open.spotify.com/track/7tT6XVWfjtpNF8enpFpZT4 [privacy] => Array ([value] => [description] => [friends] => [allow] => [deny] =>) [type] => status [status_type] => wall_post [created_time] => 2016-05-12T17:33:49+0000 [updated_time] => 2016-05-12T17:33:49+0000 [is_hidden] => [is_expired] => [likes] => Array ([data] => Array ([0] => Array ([id] => 196458690716329 [name] => Funny memes pics)) [paging] => Array ([cursors] => Array ([before] => MTk2NDU4NjkwNzE2MzI5 [after] => MTk2NDU4NjkwNzE2MzI5)))) [2] => Array ([id] => 246179452202174_676411742512274 [from] => Array ([name] => LGB eSports [category] => Sports Team [id] => 246179452202174) [message] => Breaking news! Changes in the team. We are sad to announce that Aurora will part ways with Lgb Female. We wish to thank her for the time she spent with us and we wish her all the best for the future. Here's what she says about this herself: "My time with LGB eSports has come to an end. I am extremely thankful for the opportunity to grow within this team, go to amazing places and meet amazing people. I have learnt so much from this experience and I will never forget all the adventures we've had together! I would like to use this moment of change to look back and sincerely thank all my team-mates for this learning experience, Per Lilliefelth for looking after us, our sponsor Intel for taking care of us and LGB eSports for their immense contribution to helping us grow as an all-female team in Counter-Strike. I am certain I will still remain close to the team and look forward to seeing them at many future events. As for myself I am currently a free agent and look forward to continuing my journey as a competitive CS:GO player for many more years to come. Regards, Aurora Lyngdal" [picture] => https://scontent.xx.fbcdn.net/v/t1.0-0/s130x130/13174168_676411742512274_4595019159434717947_n.jpg?oh=dad6bffaf94a2eae60c578d58f7cf8fc&oe=57E7E3F3 [link] => https://www.facebook.com/LGBeSports/photos/a.252900201530099.1073741829.246179452202174/676411742512274/?type=3 [name] => Timeline Photos [icon] => https://www.facebook.com/images/icons/photo.gif [privacy] => Array ([value] => [description] => [friends] => [allow] => [deny] =>) [type] => photo [status_type] => added_photos [object_id] => 676411742512274 [created_time] => 2016-05-04T15:08:52+0000 [updated_time] => 2016-05-11T20:30:20+0000 [shares] => Array ([count] => 4) [is_hidden] => [is_expired] => [likes] => Array ([data] => Array ([0] => Array ([id] => 1756499731303402 [name] => Antony Giordans) [1] => Array ([id] => 196458690716329 [name] => Funny memes pics) [2] => Array ([id] => 10205058377778051 [name] => Charmaine Anne D. Better) [3] => Array ([id] => 992479757539742 [name] => Yunus Emre Çeker) [4] => Array ([id] => 244636029237859 [name] => Roman Hardinger) [5] => Array ([id] => 1134092109982746 [name] => Khoa Nguyen) [6] => Array ([id] => 525969817592366 [name] => Joseph Turton) [7] => Array ([id] => 1152533898100318 [name] => Kristian Sørensen) [8] => Array ([id] => 1193252910715325 [name] => Kamil Grochu Groszek) [9] => Array ([id] => 1158759100821275 [name] => Ace Kjirkovski) [10] => Array ([id] => 10153477966360064 [name] 

ответ

0

вы должны повторить эту переменную

$data[0][0]['message'] 
+0

Вывод пустой, так что не работает:/ – mezt

+0

$ данных [0] [0] ['message'] – Eugene

+0

выполните этот код и дайте мне вывод print_r (($ data)); –

Смежные вопросы