Create a photo album on Facebook through the Graph API - facebook

I am trying to create a FB photo album, so that I can use that album in a FB AD. I am using the following request on fiddler:
POST https://graph.facebook.com/v2.5/{page_id}/albums
and I pass the page access token in the body of the request. I keep getting this reply:
{"error":{"message":"(#200) Requires extended permission: manage_pages and publish_pages","type":"OAuthException","code":200,"fbtrace_id":"FCspsWIecMV"}}
After a lot of research, I found this video: https://www.youtube.com/watch?v=vZ28bjBNk6I
This video shows how to give extended permissions, which seems to be the problem, but it is not working properly. I used the following query to give the necessary permission to myself:
https://graph.facebook.com/oauth/authorize?client_id={ap_id}&redirect_uri={our_page}&scope=publish_pages
But it only redirects me to the 'our_page' link. But the first time I have used this link, with "manage_pages" in the scope, it actually has shown me the page in which I had to allow this permission. So I guess the query is correct, because by querying the /me/permissions I get this:
{
"data": [
{
"permission": "manage_pages",
"status": "granted"
},
{
"permission": "public_profile",
"status": "granted"
}
]
}
Any tip on how I can get this done?

I found out that, by selecting the app in the https://developers.facebook.com/tools/explorer, the necessary permissions are then shown for the specific request. After clicking there, all my requests started to work, so it seems that this method is permanent. Below there's an illustrative screenshot of how to do it.

Related

Missing attributes with Facebook Graph API Photo Node

I have an access token with the manage_pages scope. Using this token, I call the endpoint specified here (GET /{page-id}/photos?type=uploaded).
The result is for some reason lacking all attributes except id and created_time. This is a part of the response:
"data": [
{
"created_time": "2018-10-30T18:12:31+0000",
"id": "1172525292900120"
},
{
"created_time": "2018-10-30T18:10:08+0000",
"id": "1172524459566870"
}
]
The docs says that data should contain "A list of Photo nodes". Looking at the photo node docs, it seems they have exactly what you'd expect.
My app does not have the permission Page Public Content Access yet. But according to their App Review section, it isn't needed for accessing my own page's content. And then again, I wouldn't even be able to get a list of photos if I didn't have access to the page.
While you are testing your app and before you submit it for review, your app can only access content on a Page for which the following is true: The person who holds the admin role for the Page also holds an admin, developer, or tester role on the app.
Why am I missing some attributes in the Photo nodes?
I had to specify which fields to retrieve like this: GET /{page-id}/photos?type=uploaded&fields=images.

Posts from Instagram not showing up on Facebook Open Graph API

I have an issue with Facebook OpenGraph API. Whenever I request data using either '/home' or '/feed', none of the posts from Instagram showed up.
I've been googling around and apparently some people raised the same issue with no solution yet. And I read some that the issue not only affecting posts from Instagram, but also other third-party app/device/platform.
Even the ticket posted on Facebook's dev page seems somewhat dead (no continuation). Link: https://developers.facebook.com/bugs/110563582419837/
If any of you guys also stumbled on this issue and has some ideas/pointers/links, please do share and let's discuss it.
Much appreciated. Cheers!
There are two bug reports in Facebook's bug tracker about this:
https://developers.facebook.com/bugs/110563582419837 and https://developers.facebook.com/bugs/202119973248747
The core reason is that the photos are attached to Open Graph actions as User Generated Photos and not via the regular Photo upload API.
As such, the regular photos permissions don't grant access to them and you need the user to specifically allow you the access their Open Graph activity for the app that posted the actions. The bug reports above are accepted on the basis that this appears to be an oversight in the case of actions with user generated photos, but it could also be by design in which case what i've outlined below as a workaround would be the only supported way to do this:
If you specifically need to request Instagram (or another Open Graph photos app) photos for a user, you can ask for Permission to access the actions posted by that app.
For Instagram photos you can do this by requesting the user_actions:instapp permission and once you've done that the Instagram Photos album will no longer appear to be empty, and the Instagram activity will appear in the feed connection.
To find out the namespace for an arbitrary app, access https://graph.facebook.com/<APP ID> and look for the namespace field,
e.g. for instagram, a call to https://graph.facebook.com/124024574287414/?fields=id,namespace returns:
{
"id": "124024574287414",
"namespace": "instapp"
}
A sample photo from my own /feed connection, retrieved with the read_stream, user_photos, user_actions:instapp permissions, is:
{
"data": [
{
"id": "[SNIPPED]",
"from": {
"name": "[SNIPPED]",
"id": "[SNIPPED]"
},
"picture": "[SNIPPED]",
"link": "https://www.facebook.com/photo.php?fbid=[SNIPPED]",
"icon": "https://fbstatic-a.akamaihd.net/rsrc.php/v2/yb/x/StEh3RhPvjk.gif",
"privacy": {
"value": ""
},
"type": "photo",
"object_id": "[SNIPPED]",
"application": {
"name": "Instagram",
"namespace": "instapp",
"id": "124024574287414"
},
"created_time": "2013-01-07T17:33:04+0000",
"updated_time": "2013-01-07T17:33:04+0000",
"comments": {
"count": 0
}
},
I can also access the /photos connection of my 'Instagram Photos' album with the same permissions, and can access all Instagram 'take' actions (i.e the photos) at /me/instapp:take
Facebook employee here. Looking at the internal task that is tracking this issue, all I can say at this time is that this is an issue that we are currently aware and investigating into. If you would like to be notified of any updates, be sure to click "subscribe" on the bug report.
For the time being, I recommend finding the album ID of the user named "Instagram Photos", then calling a GET request to /INSTAGRAM_ALBUM_ID/photos to get their Instagram photos. On the Graph API Explorer tool, I confirm that I am able to fetch all of my instagram pictures. Since my album is public, you should be able to view them as well.

How to get a Facebook access token that has enough rights to get the posts in which you're tagged in?

The Facebook posts in which you're tagged in - using #Name - appear in your wall feed.
A friend of mine posted a link and tagged me in it:
On the Graph API documentation, when I click on my wall feed link (Ctrl + F: Profile feed), I'm able to see this post:
...
{
"id": "XXX",
"from": {
"name": "XXX",
"id": "XXX"
},
"to": {
"data": [
{
"name": "XXX",
"id": "XXX"
},
{
"name": "Christophe Maillard",
"id": "XXX"
}
]
},
"message": "The startup Guide (cc XXX, Christophe Maillard)",
"link": "http://mashable.com/2012/06/27/startup-guide-1000-users/",
"name": "How to Get to Your First 1,000 Users",
"caption": "mashable.com",
"description": "With the help of some smart marketers and entrepreneurs, we're created a clear outline for attracting your startup's first 1,000 users.",
...
}
...
The URL of this feed is https://graph.facebook.com/me/feed?access_token=XXX.
When copy/pasting the given access token - the one replaced by XXX in the URL above - within the debugger, I get something like this:
As we can see, the access token is generated by the app Test_console which used quite a lot of scopes.
Then, I go to the Graph API Explorer, I generate an access token using the Get Access Token button, and I specify all the scopes the debugger gave me, i.e. the ones the Test_console app used to generate its working access token. Finally, I access the URL me/feed by submitting the GET request. The problem: I can't see the post in question in which I'm tagged in with the explorer.
I also have my own app, and it reacts exactly like the Graph API Explorer: I can't find that post in my wall feed using the Graph API as well.
Obviously, it's possible to get the posts in which you're tagged in using the Graph API, because the Test_console app is able to generate an appropriate access token. But how can I get such an access token for my own app?
You need to grant the appropriate permissions for your app. In the graph api explorer https://developers.facebook.com/tools/explorer?method=GET&path=me switch to your app in the applications field (top right) to see what permissions that currently grants your app (by clicking the "get access token" button again). Then make sure you add in the correct one (i think it's read_stream you're after ) https://developers.facebook.com/docs/authentication/permissions/

Can't access news.reads actions using facebook open graph api

I have a facebook account I KNOW has articles posted to the open graph as read actions under the news.reads global namespace (I can see them under the News aggregation in my timeline) but when I try to get a list of them using this api address:
https://graph.facebook.com/me/news.reads?access_token=[my access token]
it returns:
{
"data": [
],
"paging": {
"next": "https://graph.facebook.com/me/news.reads?access_token=[my access token]&offset=25&limit=25"
}
}
as though there were no articles posted at all. I checked my permissions and cant find anything that might be causing this issue. Anyone know how I should be accessing this data correctly? Thanks!
You need the user_actions.news Permission in order to access the user's list of news reads, otherwise the array comes back empty

Remove facebook like using graph api

Using GET https://graph.facebook.com/288095787880494/likes/159222380758097 returns me
{
"data": [
{
"name": "Vote For Prophet Hazrat Muhmmad (PBUH) the best man of world",
"category": "Cause",
"id": "159222380758097"
}
],
"paging": {
"next": "https://graph.facebook.com/288095787880494/likes/159222380758097?format=json&limit=5000&offset=5000&__after_id=159222380758097"
}
}
Now i want to remove this like. How do I do that? When I use HTTP Delete I get the following error:
{
"error": {
"message": "(#3) App must be on whitelist",
"type": "OAuthException"
}
}
You are not allowed to remove likes for Facebook Pages. Only for post, comment and URL's owned by your application.
To be able to do this your application must be whitelisted by Facebook which can only be done by contacting Facebook directly (and will probably require some kind of agreement and cost you money as well...)
Sounds like maybe two issues. Maybe the same. But try what I suggest in #2. Maybe facebook is spitting out a false/misleading error message.
Your app and or page is currently on the facebook naughty list. "Error code: (#3) App must be on whitelist"
You need to use a PAGE access token and not a USER access token. "It says I need to switch back to my Username in order to do that though as I mentioned earlier this link has been liked by the Page"