Facebook Page Access Token to display ANY public fb page feeds - facebook

I'm facing trouble in getting access_token which I need to use in displaying ANY facebook feed on the website.
I have followed the instructions here in that given link, facebook: permanent Page Access Token?, but sadly not worked for me.
Below are my API details and my requirement is to display ANY facebook page posts via PHP code in my website.
App ID: 1250216098473345
App Secret: c637f7640a185b8137e567295abe568f
All I need is a non-expire access token to put in my code to display feeds.
$userPosts = $fb->get('/ESPN/posts?fields=story,shares,likes.summary(true),comments.summary(true),full_picture,permalink_url,message,updated_time&limit=8', $accessToken);
Tried given tokens to display data of public fb pages, but failed.
https://graph.facebook.com/oauth/access_token?client_id=1250216098473345&client_secret=c637f7640a185b8137e567295abe568f&grant_type=client_credentials
https://graph.facebook.com/oauth/access_token?client_id=1250216098473345&client_secret=c637f7640a185b8137e567295abe568f&grant_type=fb_exchange_token&fb_exchange_token=EAARxEJ5xJYEBAGXFLgn98sPHGqZA74pkipbxLPTCn0jx7vtZBipmoPcG7CYaBXqRol2IUhtAI9wlX4bpFOJ1oGWSEmucCzUYKQnCwH42BnCEZARuIgEPGR3r0ZCjvI343S5yLd1C8mPLQJHNKiAOskwhmP4FU0ZC6eEvVOZB1XnWYleZA639EntpCYedUNp9itjy9c2joZBZBqAZDZD

First of all you shouldn't share you app secret publicly (hence the name).
There is no token that would allow you to display any Facebook page feed. Looking at your example call you most likely refer to pages you or your app users don't have a role in therefore you can apply for Page Public Content Access feature which then would allow you to access public page's data/feeds.
The other option would be requesting manage_pages permission from a page admin for the specific page you want to access.

Related

How to get Facebook comments for a page on my website

I can use Facebook login to login as an admin of the Facebook app that represents my website. Then, I can call this endpoint:
"https://graph.facebook.com/comments/?access_token=".$tokens["access_token"]."&ids=".$source
here, $tokens["access_token"] is an access token provided by the Facebook login process and $source is the URL for which I want to get the comments.
Facebook's API response is this:
To use 'Page Public Content Access', your use of this endpoint must be
reviewed and approved by Facebook. To submit this 'Page Public Content
Access' feature for review please read our documentation on reviewable
features: https://developers.facebook.com/docs/apps/review.
Initiating the review process for my app in the Facebook developer dashboard, the requirement for obtaining access for this is:
Please give them detailed step-by-step instructions for how to see
this permission the same way people using your app would.
And:
We need to see your app using Page Public Content Access so we can
see that it doesn't violate our policies. Upload a video screencast walkthrough using any method, (even recording with your
phone).
(In both cases, the emphasis is mine.)
I can not show what I can not show. I have no access to this endpoint, so I can not show, in action, my site using this endpoint.
What's more, I am the admin of the Facebook app representing the website for which I want to get access to the comments, and want to access the comments through that, my, account, only; I don't want any regular user account to access the comments for the pages on my website.
So, how do I get programmatic access to the Facebook comments made on pages on my website?

Querying Facebook Status Updates of a profile

I have a website that query Facebook graphApi and get the available public data of pages.
I have some profiles, where graphApi does not return any data i.e. post/status data marked public on profile.
Even when I try to visit profile manually i.e. by typing url in IE - https://www.facebook.com/ndalloul, it redirects me to Facebook login page.
But when I do it manually i.e. login to my Facebook Account and try to view the profile Ex:https://www.facebook.com/ndalloul shows me the data marked as public.
How to get this data from Facebook using API or Library?
Any help is appreciated.
Thanks.
Apart from the fact that Facebook is switching to the Graph API 2.0, you should not get any kind of redirect to login if you use your app access tokens and talk to the graph via cURL 8ro qeuivalent) .
The endpoint to get public statuses from fan pages, is page_id/feed/ You need an access token from an app with with read_stream permission and only those who grant you that permission will show the latest posts. More info here
You may now have to be approved by facebook to read the stream, by the way.

Getting page access_token for a Facebook page (using Graph API)

I am trying to access a public FB community page and display the images on web page, example-http://www.codeofaninja.com/2011/06/display-facebook-photos-to-your-website.html
My site is being developed in java, so I am looking for a core java solution to do something like this.
My site does not prompt for the user to login via Facebook or authenticate. I am simply trying to display all the images from my own album on my website.
I have created an FB app, and then created a community page on which I have my pictures.
I am struggling to I authenticate from the backend code of my with my app or page. My app has user_photos permission and the App Type (Apps->Your APP->Advanced->App type) is Web.
Here are the things I tried using graph API:
1) Get access token
https://graph.facebook.com/oauth/access_token?client_id=ABC&client_secret=XYZ&grant_type=client_credentials
2) Then use access token to get access to the page and its albums, but the above gives me app access_token. As mentioned on Graph API documentation for Page it requires a page acess_token, but I am not understanding how do I get the page_access_token via an app access_token with a backend application.
After Page access token is retrieved I can use the following call to retrieve all photos.
https://graph.facebook.com/PAGE_ID/photos?access_token=<page_access_token>
You can make the following Graph API call To get the page access tokens for all the Pages a particular user admin.
https://graph.facebook.com/user_id/accounts?access_token=<user_acess_token>
the app access token that you're retrieving from
https://graph.facebook.com/oauth/access_token?client_id=ABC&client_secret=XYZ&grant_type=client_credentials
can be used to access the public data on a page - you don't need a specific 'page' access token.
this page https://developers.facebook.com/tools/explorer/ is handy for testing things out - plug in the app access token and the page url to try it out
but I am not understanding how do I get the page_access_token via an app access_token with a backend application.
Not at all …
To get a page access token, you have to have a user access token with manage_pages permission first.
(If you get a long-lived user access token, and use that to get the page access token, then the latter will not expire by default.)

Facebook Graph Api access Alcohol Related Page

I am looking for a solution to fetch the feeds of an alcohol-related/age-restricted Facebook Brand Page by a website or back-end service to show these infos in that website for any user.
i.e: https://graph.facebook.com/JimBeam
The standard call results with an error or false.
I know the reason is the age-restictrion because of the relation to alcohol.
If I am connected to Facebook and add an access_token (user-token or page-token) to the request, I get everything I need, but it doesn't work if I am not connected.
If I request the page-token with offline_access, it also does not work when I am not connected to Facebook.
I am a bit confused with all this token types, offline_access, permissions and so on.
Is possible to get the fb-graph-feed of an age-restricted page and load that into a website?
To get an age-restricted feed you need to have a user access token that meets the criteria for the page. So if a user is visiting your site, they will need to authenticate your app, and then you can use the resulting access token to pull information to your website from that restricted page.
You should not be using a user's access token to display content to another user who does not meet the restrictions on the Facebook page.
An added problem is that Facebook does not expose a page's restrictions via the API, so you can't tell if a user has permission to see the page until your API request returns no data.

facebook: how to grant a website permanent access to your wall?

I am creating a website and I would like it to display the posts present on the wall of my own Facebook profile page. These posts must be visible to any user visiting my site.
Having read various articles online regarding the topic of the Facebook api, I had thought I had found the correct solution. The following steps are what I have done thus far:
Signed in as a developer on Facebook (I am only allowed a max of 2 URLs in the post hence I have ommitted the URL)
Set up a new app which gave me an App ID and an App Secret.
Generated my access token at the following URL:
https://graph.facebook.com/oauth/access_token?grant_type=client_credentials&scope=offline_access&client_id=APP_ID&client_secret=APP_SECRET
Where APP_ID and APP_SECRET are the App ID and App Secret from step 2. I also added the 'scope' parameter and set it to 'offline_access' as I believe this is what would allow my website to access my Facebook wall information without needing me to be currently logged into Facebook.
When I access my test page at [http://pauldailly.javaprovider.net/danceclass][1] (I set this URL to be my 'site URL' when creating my app in step 2. Similarly, I set my 'Site Domain' to be the same as my site URL, without the '/danceclass'). I get the information message 'Paul Dailly has not shared any information' and it displays my Facebook profile image. I should point out that this test page is using the Facebook Wall jQuery plugin to make the call to facebook. I have supplied the plugin my facebook page's profile ID and the access token that I generated above.
My question is, do I need to take some extra step in order to allow my site to now access specific pieces of data from my Facebook account, such as my wall posts, now that I appear to have a valid access token?
First, a access token can expire in many ways,
1. Time.
2. When you log out.
3. When you change permission etc.
Second, yes you need different permissions from the user (even if the user is app admin) to retrieve different bit of information from his Facebook profile.
And also, make sure you construct meta tag currectly in your website, like putting og:admins, og:app_id etc. You have to supply the app_id when initiating the facebook (php/js)-sdk in your website too.