I'm having trouble processing my facebook feed using simplexml

http://www.facebook.com/feeds/share_posts.php?id=207302593&viewer=207302593&key=d95b2de790&format=rss20

The link above is the URL of my shared Facebook posts. When I load this URL into simplexml_load_file (), it contains the entire error page. Looking at the bugs, it looks like Facebook is splashing out HTML instead of feed. I thought this was an authentication problem, but I logged out of facebook and uploaded the channel url to my browser and I was able to see the feed. Here are the errors I get. Any ideas? Thanks!

A PHP Error was encountered

Severity: Warning

Message: simplexml_load_file() [function.simplexml-load-file]: http://www.facebook.com/feeds/share_posts.php?id=207302593&viewer=207302593&key=d95b2de790&format=rss20:12: parser error : AttValue: " or ' expected

Filename: models/Stream.php

Line Number: 55

A PHP Error was encountered

Severity: Warning

Message: simplexml_load_file() [function.simplexml-load-file]: </script><noscript> <meta http-equiv=refresh content="0; URL=?_fb_noscript=1" />

...
+3
source share
1 answer

"" Facebook. .

echo file_get_contents('http://www.facebook.com/feeds/share_posts.php?id=207302593&viewer=207302593&key=d95b2de790&format=rss20');

, Facebook User-Agent "" ( PHP ), , . , , , . ( , , , ).

, , Facebook. , , ( curl http).

curl - , PHP ini

    ini_set('user_agent', 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3');
+12
source

Source: https://habr.com/ru/post/1719222/


All Articles