Querying Facebook Status Updates of a profile - facebook

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.

Related

Facebook Page Access Token to display ANY public fb page feeds

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.

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.

No access token facebook application authentication

I'd like to show my facebook wall posts on my website.
So i don't want to authenticate users with a dialog, to grant them some rights, i just want to show him my wall with comments (no ability to add comment just read only access).
As i know there isn't unexpired tokens now so is it possible to access just my data without requesting token every time it expires?
I'm using asp.net mvc but i think this sultion doesn't depend at platform at all.
You should:
Make your Facebook Posts public
Call the API endpoint: https://graph.facebook.com/{your_id}/feed?access_token={app_access_token} with your user_id and valid application access_token
Show the results on your website.
The App Access Token doesn't expire so you won't have a problem. As long as the posts are public, the API will be able to pick them up. In theory, your posts should be public anyway so anonymous users can see this.
This also gives you the ability to share stuff privately and not have it show up on your website.

How to get the access_token for Facebook with no application

On the documentation page for Facebook Graph API there are a lot of example links such as https://graph.facebook.com/me/likes?access_token=SOME_AT
Could anyone explain how the access_token for these links are generated?
All I've read in the documentation were about getting access_token only for applications, but on that page everyone could get an access_token without one.
You can use the graph API to get public information. People set privacy settings on facebook, so to prevent social freaks from stalking you, they(fb) created Autorisation.What I believe is that on the documentation, they are generating the access token using the Developers App. You can generate this Access token by making an application and asking a user to Authorise your application to access his data using OAUTH dialogs. Usually people reading at developer.facebook.com have enabled the Developers app so it easily opens your information.
The Graph API as such allows you to
easily access all public information
about an object. For example,
https://graph.facebook.com/btaylor
(Bret Taylor) returns all the public
information about Bret. For example a
user's first name, last name and
profile picture are publicly
available.
To get additional information about a
user, you must first get their
permission. At a high level, you need
to get an access token for the
Facebook user. After you obtain the
access token for the user, you can
perform authorized requests on behalf
of that user by including the access
token in your Graph API requests:
The access_token in these links are generated using your Facebook identity and an application ID (presumable associated to "developers.facebook.com"). If you go to the same page with another Facebook account, you will see different access tokens.