Remove facebook like using graph api - facebook

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"

Related

Create a photo album on Facebook through the Graph API

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.

Create a Link Ad for a Facebook object (event url)

In business manager it's possible to create a Link Ad with a Facebook Event url. I like to do the same with Facebook Ads API but facing a permissions error.
The Ad Creative of an Ad created in business manager looks like this one:
{
"object_story_spec": {
"page_id": "24188824589????",
"link_data": {
"link": "https://www.facebook.com/events/25595316793????/",
"message": "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
"image_hash": "cbb1f226fd5fe47c826dd1cad117????"
}
}
}
When I am trying to create the same Ad Creative via Ads Api I get an error message like the following:
{
"error": {
"message": "Invalid parameter",
"type": "FacebookApiException",
"code": 100,
"error_subcode": 1349118,
"is_transient": false,
"error_user_title": "Disallowed Post Link",
"error_user_msg": "One or more of the given URLs is not allowed by the Stream post URL security app setting. It must match the Website URL or Canvas URL, or the domain must be a subdomain of one of the App's domains. Read https://developers.facebook.com/docs/facebook-login/security/ to learn more about app settings related to security."
}
}
I get the same error if I try to create a Link Post with Graph API separately to use as object_story_id.
We really need this kind of Ads for our business. In stream ads perform much better than display ads. Is there anyway to create ads like this one via Ads API?
You should check the migration settings for your app to see if "Steam post URL security" is enabled.
This prevents URLs being posted by your app which do not link to a domain listed in your app settings.

Can't get Facebook user id by Graph

I'm working on an iOS app and noticed that one user is not loaded when I do a requestForMyFriends.
After looking more into this it seems that the Graph API explorer also doesn't return anything for the particular Facebook user. It's a user and not a Fanpage or something.
So:
I've the page for example (which when I enter In my browser will bring up the Page nicely): https://www.facebook.com/user-name
https://graph.facebook.com/https://www.facebook.com/user-name
Will return:
{
id: "https://www.facebook.com/user-name"
}
https://graph.facebook.com/user-name
Will return:
{
error: {
message: "Unsupported get request.",
type: "GraphMethodException",
code: 100
}
}
http://findmyfacebookid.com/ wil return nothing.
The graph API will return:
{
"error": {
"message": "Unsupported get request.",
"type": "GraphMethodException",
"code": 100
}
}
I'm trying to reproduce this with my test Facebook account and put all restrictions to the max but I always get a nice result with a FacebookId.
My question:
What settings do I need to change to my test Facebook account to reproduce this problem?
"Unsupported GET Request" covers many situations, but at the root the message means you tried to request something via the API which is not available to you via the API
For a request which attempts to retrieve data about a known username or user ID the most likely reasons are:
User has blocked your app
User has disabled all platform apps in their privacy settings
User has deactivated their account
User has deleted their account
if i had to bet, I'd say it's the second one in this case
The problem is the parameter, you don't have to pass in the whole URL of a profile, just the username/profile-id.
For example: we want to get the info of Mark Zuckerberg. His Facebook username is zuck. The URL would be https://graph.facebook.com/zuck and will return the following output
{
"id": "4",
"name": "Mark Zuckerberg",
"first_name": "Mark",
"last_name": "Zuckerberg",
"link": "http://www.facebook.com/zuck",
"username": "zuck",
"gender": "male",
"locale": "en_US"
}
Using https://graph.facebook.com/4 (4 is the profile id of Mark Zuckerberg) would produce the same output.
Edit
After some further investigation it turned out that said user might have deactivated her account and that is why you see this error. I have used a testuser of one of my apps, went to Settings -> Security -> Deactivate my account and taxa, every request to the Graph API returned the result you're seeing.

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/

How do I add a custom tab to a Facebook application profile page programmatically?

I am able to add custom tabs to my Facebook pages, by using the Graph API,
[https://graph.facebook.com/page_id/tabs] and using HTTP POST.
However, I am unable to add custom tabs to my Facebook application's profile page. Infact the API, [https://graph.facebook.com/page_id/tabs], with HTTP GET also fails.
(I mean, I cannot even get the tabs for my Facebook application's profile page with the API.)
What am I doing wrong?
Here I am listing what I am trying to do:
I get an access_token (say a1) for a user (admin_user) using the manage_pages permission.
With this access_token (a1), I use Graph API, >[https://graph.facebook.com/me/accounts] and get back a list of pages (pages and application profile pages):
{
"data": [
{
"name": "Bg",
"access_token": "***",
"category": "Industrials",
"id": "*****"
},
{
"name": "Testapp2Pip",
"access_token": "*******",
"category": "Application",
"id": "***"
},
Now I use the Graph API, [https://graph.facebook.com/page_id/tabs]
Case 1. If I use the page_id for the background page (which is a normal page) and the corresponding access_token, I get back the tabs for the page.
Case 2. If I use the page_id for the Testapp2Pip page (which is an application profile page) and the corresponding access_token, I get an error:
{
"error": {
"message": "Unsupported get request.",
"type": "GraphMethodException"
}
}
What am I doing wrong here? How do I get the tabs for an application profile page? Also, I would actually want to add custom tabs to the application profile page by using Graph API.
Have you added the app to the app profile page, and/or double checked that it is added as an app? It seems odd, but you can add/remove the app from the apps own page. I'm guessing if the app isn't added, then it wouldn't have access to the page information.
An alternative option is to get an access token for the application, not the current user. This page has instructions for getting an access token for the app, instead of the user. Scroll down to the "App Login" section.
http://developers.facebook.com/docs/authentication/
Okay, so this is a bug. I have filed the bug with Facebook.