简体   繁体   中英

Facebook API / iOS SDK / retrieve page posts without login

Is it possible to retrieve Facebook page posts in an iOS application without having to use Facebook Login?

I am currently using the Tumblr API which works perfectly fine and delivers pictures and texts from everything that has been posted.

Any help would be much appreciated.

Thanks.

Facebook SDK says, that you need any valid access token if the post is public. So just use your app access token.

Read how to request app access token here.

Yes, this is possible. There are two options from my point of view:

  • If your Page is only posting in public, you could use an App Access Token
  • If your Page also contains non-public Posts, you should use a Page Access Token

See https://developers.facebook.com/docs/graph-api/reference/v2.0/page/feed/#readperms

  • An access token is required to view publicly shared posts.
  • A user access token is required to retrieve posts visible to that person.
  • A page access token is required to retrieve any other posts.

An App Access Token will not expire unless you change your App secret, a Page Access Token will expire the latest 60 days after issuing.

You should consider to wrap this in an own webservice, so that you don't have to hard-code an Access Token into your App. With an own webservice, you could encapsulate the Access Token validity issues.

I recommend their graph api for such tasks Using it I have successfully retrieved page level data using Facebook graph api(REST)

using an app token(public posts) 
user token(posts visible to that user) or 
page token(all posts in page)

App token is obtained by default on creation of your Facebook app(easiest way)
User token is obtained on a user oauth login(needs oauth,can be done with oauth libraries)
Page token is obtained with a second call to Facebook, after obtaining the user token if you have manage_pages permission from the page admin (needs oauth and a second call to Facebook)

Try Facebook graph explorer and hit the page URL to get a json response of your page information.

Play with the graph explorer
https://developers.facebook.com/tools/explorer/

Page data reference
https://developers.facebook.com/docs/graph-api/reference/v2.0/page/

Access token reference
https://developers.facebook.com/docs/facebook-login/access-tokens

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM