New facebook app cannot access comments but old one can - facebook

I have two facebook apps. I am trying to access comments from posts using the graph api. Use an access_token from the old app I can access comments from a non-public post like this:
https://graph.facebook.com/{post-id}/comments?access_token={access-token}
When I do this, I get json for all the comments on the post just as I would expect. But if I use an access token from my new app, when I make the same request I always get an empty data set like this:
{
"data": []
}
If I make a request for a public post using the new app, I get results. It is just the non-public posts that I get the empty dataset. I checked and double-checked all the settings in both my new and old app, and the only difference I could find was that the old app has an alert that I need to fix "July 2013 Breaking Changes".
Could this be what makes the difference? If I mark the old app as being fixed for "July 2013 Breaking Changes" will it stop working correctly too? Where else should I check?

Related

Is fb graph user search api not working anymore?

https://graph.facebook.com/search?q=sharma&fields=name&type=user&access_token=
I was this URL along with access token and it was giving me user name list that i was using in my project. Only names are my requirement but when today i started to use it i am not getting any data nor any error.
Its only returning this
{
"data": [
]
}
Recently a month ago it was working for me.
Can anyone tell me if they have the same issue or if something has changed?
Is there any other was of getting users name mainly first + last name from fb?
I have found answer of my question which is Fb is no more giving user results for graph search api.
https://developers.facebook.com/docs/graph-api/changelog/breaking-changes#search-4-4
Search API
You can no longer use the /search endpoint with the following object types:
event
group
page
user
I dont know whether its a permanent revoke or temporary but it has something to do with Cambridge analytica data leak issue
https://www.google.co.in/search?biw=1360&bih=662&tbm=nws&ei=-iTXWrrkCYrxvgTTy5GgCw&q=cambridge+analytica+data+leak&oq=cambridge+analytica+data+leak
I hope it will help others to find out why their API is not working anymore.

Empty response to API call to Facebook Graph

I have been hammering away at this problem for the last day. I really hope someone can help me out. I would be very grateful.
What I am trying to do is fetch event data from a Facebook Page. I looked over the documentation, which says this about reading Pages data:
Reading
A Facebook page
Permissions
For pages that are published, you need:
An app or user access token to view fields from fully public pages.
So what I did was I obtained an app access token via:
GET https://graph.facebook.com/oauth/access_token?
client_id=YOUR_APP_ID
&client_secret=YOUR_APP_SECRET
&grant_type=client_credentials
which then returned
access_token=MY_APP_ID|MY_APP_ACCESS_TOKEN
After this I followed the documentation and made the following call
https://graph.facebook.com/v2.4/129511477069092/events?fields=id,cover,name,venue,description&access_token=MY_APP_ID|MY_APP_ACCESS_TOKEN
This returned:
{
"data": [
]
}
So after some fiddling around I was able to make the call by switching to version V2.2 and by creating an access key with Facebook API Graph explorer tool(no permissions granted).
GET https://graph.facebook.com/v2.2/129511477069092/events?
fields=id,cover,name,venue,description&
access_token=ACCESS_TOKEN_FROM_FACEBOOK_API_EXPLORER_TOOL
The page I am trying to retrieve data from is public and so are the events, so I can't figure out what is going on. I know I am super close since I am able to retrieve the data with the token provided by the Facebook API Graph Explorer Tool. The thing with using this token is that it only last a few hours and I need something that is going to last longer such as an app access token. I have done some research on Stackoverflow and found similar questions, but none of them solve my problem. Any help will be appreciated to the max! Thanks.
Looks like a bug of v2.4 to me. It works with v2.3 if you remove the deprecated venue field:
https://developers.facebook.com/tools/explorer/145634995501895/?method=GET&path=129511477069092%2Fevents%3Ffields%3Did%2Ccover%2Cname%2Cdescription&version=v2.3
If the version is changed to v2.4, it returns an empty result.
https://developers.facebook.com/tools/explorer/145634995501895/?method=GET&path=129511477069092%2Fevents%3Ffields%3Did%2Ccover%2Cname%2Cdescription&version=v2.4
There's no documentation about this in the changelog at
https://developers.facebook.com/docs/apps/changelog#v2_4
so I guess it's a bug. There's already a bug report at
https://developers.facebook.com/bugs/443054055873667/
with status assigned. If you have an app that supports v2.3, I'd suggest you prefix your request like this:
GET /v2.3/129511477069092/events?fields=id,cover,name,description

Facebook graph api - Unsupported get request

I'm creating a custom module in Drupal, that for part of its functionality must fetch posts from a business page. So for simplicity, I'm using fbapp module as a dependency (drupal.org/project/fbapp), so that I can use it's authentication and request functions (fbapp_app_authenticate() and fbapp_graph_request()) without having to worry about the constant facebook graph updates making my own code obsolete.
I've created a facebook app, so authentication should be app token, using appid and app secret. This seems fine and I'm getting back access_token. However, when I try to read posts from a publicly available page (the clients), I get the response:
"Unsupported get request. Please read the Graph API documentation at https:\/\/developers.facebook.com\/docs\/graph-api"
Here's the queries and responses my code produces:
graph.facebook.com/oauth/access_token?client_id=<redacted>&client_secret=<redacted>&grant_type=client_credentials
array(1) {
["access_token"]=>
string(43) "<redacted>|<redacted>"
}
graph.facebook.com/<page_id>/posts?access_token=<redacted>|<redacted>"
string(183) "{"error":{"message":"Unsupported get request. Please read the Graph API documentation at https:\/\/developers.facebook.com\/docs\/graph-api","type":"GraphMethodException","code":100}}"
Can anyone verify a correct way to query a Facebook page programmatically, perhaps there's a setting in the page I'm querying that I need to set (although I can't find anything)?
If page restrictions apply, the page's feed can only be retrieved with an user access token as far as I know (because FB needs to evaluate the visibility criteria, and setting your app to the same restrictions doesn't help here):
See
https://developers.facebook.com/docs/graph-api/reference/v2.4/page/feed#readperms
It looks like everything you have done is correct. The response you got can be (i am not sure) because you got your clients pageid wrong.

Can you use the Facebook API to delete old posts?

I am new to using the Facebook API and just started playing around with it.
I was wondering if it is possible, for example an app, to delete past posts (that exists on the timeline, i.e, Can an app have the functionality to delete posts that exists before the app was started?)
Thanks.
Looking at the relevant documentation, you are able to delete a post only if it was your application that created it.
An app can delete a post if it published it
You have not stated which language/SDK you are using, but the above link has examples for each supported SDK.
Here is an example using the PHP SDK:
$response = $facebook->api(
"/{post-id}",
"DELETE"
);
What you would need to do is make a DELETE request to /post_id.
Keep in mind that you will need the publish_actions permission to perform this action.
This is tricky - the answer is yes and no.
You can use the API to get a list of old posts, but then you need to delete them via the browser. This tool does just that:
https://github.com/chander/social-network-cleaner
However, it's written in Python and requires a bit of tech know-how.
This is possible now
Delete a Post
To delete a Page post, send a DELETE request to the /{page-post-id} endpoint.
Before You Start
You will need the following:
The pages_manage_posts permission
The pages_read_engagement permission
A Page access token requested by a person who is able to perform the CREATE_CONTENT task on the Page that is being queried
Sample Request
curl -i -X DELETE "https://graph.facebook.com/{page-post-id}
?access_token={page-access-token}"
On success, your app receives the following response:
{
"success": true
}

How to delete a Facebook comment post using the Facebook GRAPH API?

I started researching this because I wanted to be able to delete a comment on the wall of a Facebook Event, because the "Remove post" doesn't seem to be applicable to comments on an Event wall. However, since I don't know if it is even possible I decided to see if I could mannually delete a post I made to my own wall first since that is possible. Note I am NOT using any SDK; I am just building the URL and entering it in the address bar in Firefox v3.6.17.
These posts have helped me alot since I am now starting:
Delete facebook post with Graph API - trouble getting this to work and
Facebook SDK and Graph API Comment Deleting Error
I can see the comment data and all its field via the following:
https://graph.facebook.com/[POST_ID]?access_token=[ACCESS_TOKEN]
`where [POST_ID] and [ACCESS_TOKEN] were got using the graph API.`
However, where do I put the "method=delete" command in the URL? I tried putting it at the end, like
https://graph.facebook.com/[POST_ID]?access_token=[ACCESS_TOKEN]?method=delete
but that results in a OAuthException stating "Invalid access token signature" because it seems to read the method as part of the access token.
I tried putting it after the post_id like
https://graph.facebook.com/[POST_ID}?method=delete?access_token=[ACCESS_TOKEN]
but that results in an Exception (Unsupported method) because it thinks "access_token=[ACCESS_TOKEN]" is part of the method being called.
I see one of the posts cited above states I have to prepend the userid to the object ID when deleting by using
DELETE https://graph.facebook.com/673509687_104812882909249?access_token={access_token}
`where 673509687 is my userID and 104812882909249 is the objectID`
But when I enter
DELETE https://graph.facebook.com/[POST_ID}?access_token=[ACCESS_TOKEN]
in the Firefox address bar it doesn't recognize it (I didn't think it would anyway) and uses it as a google search query.
How do I delete a comment if I have the comment_id and my access_token using the web browser?
You have a big problem with your urls :
https://graph.facebook.com/[POST_ID]?access_token=[ACCESS_TOKEN]?method=delete
Should be :
https://graph.facebook.com/[POST_ID]?access_token=[ACCESS_TOKEN] & method=delete
Identically,
https://graph.facebook.com/[POST_ID}?method=delete?access_token=[ACCESS_TOKEN]
should be :
https://graph.facebook.com/[POST_ID}?method=delete & access_token=[ACCESS_TOKEN]
So you have to use the ? before entering your parameters and then & between each parameter and the order should not have any importance ..