Facebook API permissions issue for Instant Articles - facebook-graph-api

I am trying to make a POST request to the Facebook API to create instant articles, like so:
curl \
-F 'access_token={access token}' \
-F 'html_source="<!doctype html><html>blah blah blah</html>"' \
-F 'published=true' \
-F 'development_mode=false' \
https://graph.facebook.com/{page-id}/instant_articles
I am an admin for the app, and when I debug my access token, the scope shows email, pages_show_list, pages_manage_instant_articles, public_profile, but the request returns this error:
{"error":
{"message":"(#200) Requires pages_manage_instant_articles permission to manage the object",
"type":"OAuthException",
"code":200,
"fbtrace_id":"Exyv2VtZ5m4"}
}
Anyone have any ideas about what's going on? Thanks and let me know if you need more info!

Solved! I added the version to the url.
https://graph.facebook.com/v2.7/{page-id}/instant_articles

When I first worked with Graph API I faced the same issue but that was in Android.
Although the solution in my case, user / admin have to sign in first and give permission to access facebook data using GraphAPI

Related

Facebook Marketing API Ads Insights

I'm currently trying to access, through my marketing app, all the insights of my ads/campaings/ads account (clicks,impressions,etc). The tokens I generate has permissions for ads_management,ads_read,read_insights and manage_pages.
Nevertheless, I always get this answer:
{"data":[],"paging":{"cursors":{"before":"MAZDZD","after":"LTEZD"}}}
(I get that response after I post something like
curl -G \
-d "fields=impressions" \
-d "access_token=my_access_token" \
"https://graph.facebook.com/v2.8/act_MyAccountNumber/insights"
And then make a get using the report id, when the report id is completed)
I added my account as admin of the app and also added it in the Authorized Ad Account IDs list.
My app has development level access.
What am I doing wrong?
Are you sure you had impressions recently?
Because I observe similar thing when try to access it with default date_preset that is 30 days:
> get "act_*****/insights", "impressions"
=> []
> get "act_*****/insights?date_preset=lifetime", "impressions"
=> ["11"]

How to revoke user permission on Socialite

I want to revoke the permission user gave me on Facebook, if he denied to give me Facebook's email. How can I do that?. I'm using Socialite on Laravel 5.2
Thank you
DELETE /{user-id}/permissions/{permission-name}
DELETE /{user-id}/permissions
This is explained in the official docs: https://developers.facebook.com/docs/facebook-login/permissions/requesting-and-revoking#revoking
You can revoke permissions and even the general authorization.
I have the same problem as you.
Reading the Facebook Graph API documentation, I found the same orientacions as luschn, but it did not solve my problem.
How I solved it
use GuzzleHttp \ Client;
$ http = new Client ();
$ req = $ http-> delete ("https://graph.facebook.com/v3.0/{USER ID} / permissions? access_token = {API TOKEN}");
I found the token API on the token generator: https://developers.facebook.com/tools/explorer/
So I made the direct request, I believe it is not the best form but solved it.
I hope this can help you and other person.

How to use access token to like fanpage

I have own access token and i would like create app, where user can like fanpage.
I tested request on graph.facebook.com. My request looks like this
http://i.stack.imgur.com/lkG7x.png
I read documentation form og.likes documentation on fb
It was not until I learn to handle fb api
How to sent such a request
curl -X POST \
-F 'access_token=USER_ACCESS_TOKEN' \
-F 'object=OG_OBJECT_URL' \
https://graph.facebook.com/[User FB ID]/og.likes
The og.likes action can refer to any open graph object or URL, except for Facebook Pages or Photos.
Source: https://developers.facebook.com/docs/opengraph/guides/og.likes
Use the Like Button Plugin instead.

Facebook OpenGraph: Submitting an new action

I'm just starting out with Facebook SSO and OpenGraph. I have SSO working with my iOS app and now I'm starting to see how to publish OpenGraph actions.
I've set up a new Action Type and I need to submit it. When I do, I get the error:
You must publish at least one action to your Timeline using this action type. Review the documentation.
Ok, so I click the helpful documentation link and it tells me I want to do this:
https://graph.facebook.com/me/recipebox:cook?recipe=http://www.example.com/pumpkinpie.html&access_token=YOUR_ACCESS_TOKEN
So I translate that into this:
https://graph.facebook.com/me/fotoferret:hug?ferret=http://www.example.com/pumpkinpie.html&access_token=MY_ACCESS_TOKEN
fotoferret is my namespace, hug is my action
where MY_ACCESS_TOKEN is the value returned by:
https://graph.facebook.com/oauth/access_token?grant_type=client_credentials&client_id=MY_APP_ID&client_secret=MY_APP_SECRET
When I pasted my translated URL I get this error back:
{
"error": {
"message": "An active access token must be used to query information about the current user.",
"type": "OAuthException",
"code": 2500
}
}
an this point I'm confused. I've tried publishing an action to my timeline, but it tells me a I need an active access token, which I've provided. So how can I publish an action?
When using an app access token please use the ID of the user not /me. You are doing actions on behalf of the app not directly of the user.
User Access Token
https://graph.facebook.com/me/fotoferret:hug?ferret=http://www.example.com/pumpkinpie.html&access_token=MY_ACCESS_TOKEN
App Access Token
https://graph.facebook.com/ID/fotoferret:hug?ferret=http://www.example.com/pumpkinpie.html&access_token=MY_ACCESS_TOKEN
When using the Graph Explorer be sure to switch the option to POST and not get GET. GET is set by default so it will return the actions not create one.
Or using cURL
curl -F 'access_token=MY_ACCESS_TOKEN' \
-F 'ferret=http://www.example.com/pumpkinpie.html' \
https://graph.facebook.com/ID/fotoferret:hug
If you have "Requires App Token to Publish" enabled and get
{"error":{"message":"(#15) This method must be called with an app access_token.","type":"OAuthException","code":15}}
It means you are using
curl -F 'access_token=MY_ACCESS_USER_TOKEN' \
-F 'ferret=http://www.example.com/pumpkinpie.html' \
https://graph.facebook.com/me/fotoferret:hug
Use MY_APP_TOKEN. If you get,
{"error":{"message":"An active access token must be used to query information about the current user.","type":"OAuthException","code":2500}}
it means you are using
curl -F 'access_token=MY_APP_TOKEN' \
-F 'ferret=http://www.example.com/pumpkinpie.html' \
https://graph.facebook.com/me/fotoferret:hug
You should use the numeric id
curl -F 'access_token=MY_APP_TOKEN' \
-F 'ferret=http://www.example.com/pumpkinpie.html' \
https://graph.facebook.com/ID/fotoferret:hug
If you get
{"error":{"message":"(#200) Requires extended permission: publish_actions","type":"OAuthException","code":200}}
The user doesn't have publish_actions actions in their set for me/permissions, it should be there as "publish_actions": 1 if it is not, grant the permission by selecting "Get Access Token" and choosing (you must change to suit in your app code scope as well)
It might be easier if you use the graph API explorer to generate an access token for you app and use that. That would at least eliminate any chance of error from your fetching the access token.

Help posting to users feeds

I have an app and I want to post to the users feed.
All the users have allowed publish_stream permission but I have no idea how to post to their feeds which I should be able to do even if the user is offline.
I want to use curl and the graph like this:
curl -F 'access_token=...' \
-F 'message=Hello, Arjun. I like this new API.' \
https://graph.facebook.com/arjun/feed
Do I simply use the access code I got when the users initially allowed me access, or do I have to get a new access code each time I want to post to their feed, if so, how do I do that?
Any help, much appreciated.
After the user authorized your application you get an access-token from facebook. You can use this token to post to the users-wall until he changes his password or removes your application from his application list.
I think you need to include your api-key in the request. Otherwise please provide the error message your getting!