Display Facebook News Feed in iPhone app for a Fac

2019-06-05 03:49发布

问题:

BACKGROUND:

There is a publicly available Facebook business page, I can see the entire page and the Facebook news feed in my web browser, without actually being logged into my Facebook account. So there is no session or authentication information to display this web page in my browser.

WHAT I WANT:

Now, I want to show the Facebook news feed for this Facebook business page as a scrolling UITableView within my native iPhone app. How do I do this?

THE PROBLEM:

When I access the Graph API explorer ( https://developers.facebook.com/tools/explorer ), I can see the albums and photos associated with a Facebook business page (ie. Pepsi), but if I try to access the news feed, like so... https://graph.facebook.com/Pepsi/feed ... it returns with an error stating "An access token is required to request this resource."

MY QUESTION:

If the Pepsi Facebook news feed is publicly viewable without being logged into my Facebook account from a web browser, then how do I show the Pepsi Facebook news feed in a native iPhone app without an access token?

Thanks

回答1:

I got into same issue after token expire introduced. But then came the idea of rss feed.

Visit https://developers.facebook.com/tools/explorer

Replace the ID in get field with your page name. So the get field link should look like:

https://graph.facebook.com/Pepsi

Submit it and in return you will get a bunch of json in the display below. You will need the very first info the id. which is 56381779049 for the Pepsi page.

Now place the id in the link below to get your desired feed.

https://www.facebook.com/feeds/page.php?id={Id we just got}&format={json|rss20}

So our Pepsi page for json feed would look like:

http://www.facebook.com/feeds/page.php?id=56381779049&format=json

Now you just have to parse and view anywhere.

You can do similar with twitter feed with link:

http://api.twitter.com/1/statuses/user_timeline.json?screen_name=anontech&include_rts=0

Where rts for retweets.

Update: Experienced some issue while fetching data from device. After this small change it worked perfectly on android as well as iOS. To solve: Change the accept header to */* or application/json as facebook is sending the response header as application/json.

header: 'Accept: application/json';

Detailed info from: cURL and Facebook problems