如何使用 PHP 仅从 Facebook 页面墙中提取消息?
我正在尝试从以下 Facebook 页面提取内容: https://graph.facebook.com/100000123344690 /feed
我已经使用以下命令成功提取数据:
$ch = curl_init('https://graph.facebook.com/100000123344690/feed');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
$response = curl_exec($ch);
$wall = json_decode($response);
var_dump($wall->data);
现在,我对如何循环 $wall 对象并输出消息参数感到困惑。有人可以向我展示一个输出消息参数的简单循环吗?
I'm trying to pull the content from the following Facebook page: https://graph.facebook.com/100000123344690/feed
I'm already pulling the data successfully using the following:
$ch = curl_init('https://graph.facebook.com/100000123344690/feed');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
$response = curl_exec($ch);
$wall = json_decode($response);
var_dump($wall->data);
Now, i'm confused on how I loop over the $wall object and output the message param. Can someone show me a simple loop outputting the message param?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您从 facebook 获取的是 json 格式的数据。您必须将其转换为数组才能循环遍历它。
您必须将 true 传递给 json_decode 才能将其解码为多维数组,请尝试:
$wall = json_decode($response, true);
print_r($wall);
what you're pulling from facebook is json formatted data. you have to convert it to an array in order to loop through it.
You have to pass true to
json_decode
to decode it to a multidmensional array, try:$wall = json_decode($response, true);
print_r($wall);
这有效:
This works: