Page Public Content Access\', your use of this endpoint must be reviewed and approved by Facebook - facebook

This is my code:
var getPageToken = 'https://graph.facebook.com/v3.3/'+pageid+'…;
request(getPageToken, function(errorPageToken, responsePageToken) {
console.log(errorPageToken);
console.log(responsePageToken);
});
For few pages I'm getting the Page Token. Whereas, with few pages I'm getting the below error.
Error:
Page Public Content Access\', your use of this endpoint must be reviewed and approved by Facebook
Few pages have access via Business Manager, few pages have access via personal account. In both cases I'm facing the issue, its very random and I'm unable to identify the cause, any help would be appreciated.

Finally figured out that the problem was with the access_token I was passing to retrieve the pageid.
I had multiple accounts set up to fetch data. While linking the page with access_token I made a mistake.
That was the cause for the error.

Related

How to access a public Facebook page using Graph API

I have a Facebook page of my own. What I would like is to access the posts in that page as a JSON by sending an API call. I do not need to return the content as a embedded web page like we get in the oEmbed. What is the approach to that?
In the Facebook developer dashboard I have created an application, which means, I have Client Token and App ID incase I need to have access_token to pass.
I know the Page ID of the Facebook page that I need to access
Is that a must Facebook Login integrated to retrieve such public page content?
When I run following command (True values of page_id, app_id & client_access removed here)
curl -i -X GET "https://graph.facebook.com/page_id?access_token=app_id|client_access"
I'm getting following error
{
"error":{
"message":"(#100) Object does not exist, cannot be loaded due to missing permission or reviewable feature, or does not support this operation. This endpoint requires the 'pages_read_engagement' permission or the 'Page Public Content Access' feature or the 'Page Public Metadata Access' feature.. Refer to https:\/\/developers.facebook.com\/docs\/apps\/review\/login-permissions#manage-pages, https:\/\/developers.facebook.com\/docs\/apps\/review\/feature#reference-PAGES_ACCESS and https:\/\/developers.facebook.com\/docs\/apps\/review\/feature#page-public-metadata-accessfor details. ",
"type":"OAuthException",
"code":100,
"fbtrace_id":"Aal5TRTWtw_phIz7-rHzj1L"
}
}
https://developers.facebook.com/docs/graph-api/reference/v9.0/page/feed
This documentation explains how to access the posts.
You will need to navigate to this URL ( https://developers.facebook.com/tools/explorer/
) and add the required permissions for page access. Then choose the Page Token on the right side where it says "User or Page"
You will need page token to access anything page related

Generate access token Instagram API, without having to log in?

So I am building a restaurant app and one of the features I want is to allow a user of the app to see photos from a particular restaurant's Instagram account.
And I want a user to be able to see this without having to login to their Instagram account, so they shouldn't even need an Instagram account for this to work.
So I have read this answer How can I get a user's media from Instagram without authenticating as a user?
And I tried what it said and used the client_id(which I recieved when I registered my app using my personal Instagram account), but I still get an error back saying :
{
meta: {
error_type: "OAuthAccessTokenException",
code: 400,
error_message: "The access_token provided is invalid."
}
}
The endpoint I am trying to hit is :
https://api.instagram.com/v1/users/search?q=[USERNAME]&client_id=[CLIENT ID]
So do I absolutely need an access token for this to work(and thus have to enforce a user to log in) ?
If I do, then is there way to generate an access token somehow without forcing the user log in?
I believe there is a way around this, as the popular dating app Tinder has this desired functionality I am looking for, as it allows you to see photos from people's Instagram account without having to log in! (I have just verified this 5 minutes ago!)
Any help on this would be much appreciated.
Thanks.
Edit April 2018: After facebook privacy case this endpoint is immediately put out of service. It seems we need to parse the JSON embedded in <script> tag directly within the profile page:
<script type="text/javascript">window._sharedData = {"activity_counts":...
Any better ideas are welcome.
You can use the most recent link
GET https://www.instagram.com/{username}/?__a=1
to get latest 20 posts in JSON format. Hope you put this to good use.
edit: other ways aren't valid anymore:
https://www.instagram.com/{username}/media/
Instagram used to allow most API requests with just client_id and without access_token, the apps registered back in the day still work with way, thats how some apps are able to show instagram photos without user login.
Instagram has changes the API specification, so new apps will have to get access_token, older apps will have to change before June 2016.
One way you can work around this is by using access_token generated by your account to access photos. Login locally and get access_token, use this for all API calls, it should not change, unless u change password,if it expires, regenerate and update in your server.
Since the endpoints don't exist anymore I switched to a PHP library -
https://github.com/pgrimaud/instagram-user-feed
Installed this lib with composer:
composer require pgrimaud/instagram-user-feed "^4.0"
To get a feed object -
$cache = new Instagram\Storage\CacheManager();
$api = new Instagram\Api($cache);
$api->setUserName('myvetbox');
$feed = $api->getFeed();
Example of how to use that object -
foreach ($feed->medias as $key => $value) {
echo '<li><img src="'.$value->thumbnailSrc.'"></li>';
}

get Facebook Graph api page review

I'm trying to get review/rating from certain place whos fb page can look like this i.e :
https://www.facebook.com/pages/Dell-Rheas-Chicken-Basket/183254918389428
So id of this place/page is 183254918389428
And you can get the details of this place but not rating/review:
https://graph.facebook.com/183254918389428
I found somewhere on this forum that you could get review from page like this :
https://graph.facebook.com/183254918389428/tabs/reviews?access_token=xxx
But I always get no data :
{
"data": [
]
}
So I'm not trying to get app review/rating but for certain place.
You'd need a page access token to fetch reviews and ratings. Here is a very good short tutorial on getting a page access token: Obtaining page access token.
https://www.facebook.com/dialog/oauth?client_id=<APP_ID>&redirect_uri=<REDIRECT_URL>&scope=manage_pages&state=<STATE>
This will generate you a CODE, use that code in:
https://graph.facebook.com/oauth/access_token?client_id=<APP_ID>&client_secret=<APP_SECRET>&code=<CODE>
This will return you a json response containing short lived user access token.
Next, use the short lived user token to get long lived user token:
https://graph.facebook.com/oauth/access_token?grant_type=fb_exchange_token&client_id=<APP_ID>&client_secret=<APP_SECRET>&fb_exchange_token=<SHORT_LIVED_TOKEN>
This will return another json containing the long lived user token, you can now exchange it for page access token:
https://graph.facebook.com/me/accounts?access_token=<LONG_LIVED_TOKEN>
This will return you a json with page access token of the page(s) associated with that user account. Use this page access token to fetch ratings and reviews by passing it to:
https://graph.facebook.com/StoneArmsInc/ratings?access_token=<page_access_token>
And you will get all the ratings posted on facebook for that page.
Hope, this helps someone. :)
The ratings edge has the reviews in it now, but you need to have a page access token to get it.
The end point is documented here:
https://developers.facebook.com/docs/graph-api/reference/page/ratings
Note that to get the page access token you have to use a user token from someone who is an admin of the page. I don't know if that's a problem for you.
The API for Page reviews hasn't been released yet. We are working on it. Please keep checking for the updates here.
Update: API for fetching page reviews can be found here: https://developers.facebook.com/docs/graph-api/reference/page/ratings/

Retrieving facebook user wall posts through graph API

I'm currently working on a facebook app which captures wall posts for a specified user, page or group, after a user has authorized the app I quote the access_token that is returned to call the method
https://graph.facebook.com//feed?access_token=
this works fine for pages and groups as we only need a valid token, however for users the results are different depending on the relationship between the user who authorized the app the user whose posts are being captured.
For example if there is no relationship between the two users some posts are not returned even though they are public and displayed when you view the profile of the user, however if they are friends more posts are returned.
Can someone please explain this behaviour? And is it possible to obtain all posts using this method?
Yes, per the permissions listed at https://developers.facebook.com/docs/reference/api/permissions the results of the call are different depending upon the relationship.
However when things are public and you use an access token that doesn't belong to the user, then no results are returned. I cannot remember a time when this wasn't this way. For some odd reason (by design or omission on Facebook's part) using the graph API to get at public posts using a user access token just doesn't want to work.
For example, You can see some public items here
http://www.facebook.com/zuck
http://graph.facebook.com/zuck
However, you cannot seem to get any feed from here without an access token
https://graph.facebook.com/zuck/feed
{
"error": {
"message": "An access token is required to request this resource.",
"type": "OAuthException"
}
}
Let's try adding an user access token that does not belong to zuck or a friend of zuck. https://graph.facebook.com/zuck/feed?access_token={UserAccessToken}
And here's what we get:
{
"data": [
]
}
What about an app access token? Let's try
https://graph.facebook.com/zuck/feed?access_token={AppAccessToken}
{
"error": {
"message": "Invalid OAuth access token signature.",
"type": "OAuthException"
}
}
So as you can see, it's difficult to get things via the graph that are not in alignment with your access token.
I manage to get most of the feeds from user's wall post. Although this is a old post, I hope someone can manage to get what they want from my answer.
Before getting the access token(to get the feeds), you need to add multiple correct Read Permissions "keys".
For example, you will have to add "read_stream", and "user_status" (which I found that these are the most important permission "key" to generate the correct access token, to retrieve one's so-called "public" feeds).
You can add more into generating the access token, in either you want the permission to GET, or POST, or BOTH.
Source is here: https://developers.facebook.com/docs/howtos/ios-6/#nativeauthdialog
One thing that I found is, the way to get the feeds result from user's "Home/About" page and Facebook Page (which is created for people to like (not add friends)) are different. The key is mentioned above, "read_stream", and "user_status". So it's better that you add both of the permissions in order to generate the access token to get everything in feeds.
Graph API doesn't return posts to the App if is not authorized to read user feed, even if posts are public.
Source: https://developers.facebook.com/bugs/290004301178437/
According to the latest api ,
FB.api("/me/feed","get",function(response) {//callback})
should do and also work well .
It is working now but facebook may change it in future.

How to get all facebook pages id associated with my account?

I want to get the statistics of all the pages associated with my account on facebook, i have the code to get the statistics of a page, i just want to get the page id of all the pages associated with my account, how can i do this?
Please help.
Thanks.
You'll need to request the manage_pages permission (more details here), once you have the aquired the permission, all you have to do is make a request to :
https://graph.facebook.com/YOUR_FACEBOOK_ID/accounts.
The return value will be a JSON with all the pages/applications that are associated with your account.
You can also use this great tool that facebook provides - The Graph API Explorer (/me/accounts) to explore what other information you can retrieve without having to write a single line of code :P very useful.
FB.api('/me/accounts', function(response) {
for (id in response.data)
{
page = data[id];
page.id;
page.name;
}
});
You can use Javascript API to do this, read more :http://developers.facebook.com/docs/reference/javascript/