Search for pages via Graph API, response empty - facebook-graph-api

When I send the request search?type=page&q=test&access_token=[access_token] to Graph API, the response is empty data. Is there a problem with the access token or is there something missing from the request URI? I also can't seem to find a comprehensive documentation of the search method, only that for places search.
This is the response I'm getting:
{
"data": [
]
}

Facebook made a lot of changes recently:
https://developers.facebook.com/docs/graph-api/changelog/breaking-changes#search-4-4
You can no longer use the /search endpoint with the following object
types:
event
group
page
user

Try this instead :
https://graph.facebook.com/pages/search?q=[PageName]&fields=id,name,link,location&access_token=[access_token]
it worked for me

Related

Facebook Graph API: Ban user function for pages doesn't work

I need to have the ability to ban users in page via API. I use next request:
POST
/page_id/blocked
data: user=user_id
It was working earlier. But now is not working. Currently I get error:
"message": "(#100) Required parameter user was not provided",
"type": "OAuthException",
"code": 100,
The documentation still: https://developers.facebook.com/docs/graph-api/reference/v2.9/page/blocked
How to make it work?
I had to change two things in order to make it work:
As the user ID came from my app, it is considered an 'app-scoped ID' (asid)
For blocking, the expected parameter is an array of IDs
POST 123pageid456/blocked?asid=[123userid456]
I got the same error, and filed a Facebook bug: https://developers.facebook.com/bugs/700023220191487/
It turns out the API does not currently support page-scoped IDs from the messenger platform. Only page IDs for the Facebook page.

Get comments of public facebook post

I'm trying to download every comment on a public facebook post (it's one of those "can you do this basic algebra problem" posts - I want to see what percent of the comments get it right).
The Graph API Reference shows that I should be able to just GET graph.facebook.com/v2.5/{object-id}/comments.
I believe the object-id of this post is {user-id}_{post-id}, where post-id is the id in the url. So given this url:
https://www.facebook.com/beth.mansfield.9/posts/10207885721596563
The user-id of facebook.com/beth.mansfield.9 is 1101752663 (from findmyfbid.com), and the post-id is 10207885721596563 (from the url), which makes the object-id="1101752663_10207885721596563".
When I try graph.facebook.com/v2.5/1101752663_10207885721596563/comments in the Graph API Explorer, though, I get:
{
"data": [
]
}
What am I doing wrong? Is there another way to get the comments? There are close to a million so loading them all in the browser and scraping with javascript would be unfeasible.
That is a user profile. You can only get data of a user profile if that specific user authorized your App. In that case, you would need to authorize with the user_posts permission. Just because it is public, does not mean you can get the data - that would only work for Pages.

Facebook Graph API v2.5 - Impossible to delete post created with a link

I'm using Facebook Graph API v2.5 to publish and delete posts from user's profiles.
I'm using Postman (Chrome extension) to test my REST calls.
Case 1) When all actually works:
- I do a POST request to "https://graph.facebook.com/v2.5/MY_USER_ID/feed", with params "access_token" and "message"
- The API returns me the created post ID, let's say "108373569531356_138530589848987"
- Then I do a DELETE request to "https://graph.facebook.com/v2.5/108373569531356_138530589848987", with params "access_token".
- My message I successfully removed from user's profile
Case 2) My issue, it does not work as expected
- I do the same POST request as previous, but I add an extra "link" parameter.
- The API returns me the created post ID.
- Then when I try to delete this post using DELETE request, the Facebook API throws me an error: "message": "(#100) This post could not be loaded"
One thing I noticed, is that first request seems to create me a Facebook "post", but the second one seems to create a "link".
I used the v2.3 API get/post_id to compare both posts, they are pretty much different.
So, why can't I delete a "link" element, the Facebook documentation does not tell anything about it.
Many thanks !
Maybe you were suffering a bug (https://developers.facebook.com/bugs/1671530079772375/) which is fixed now.
If you published a post with a link through an app being in development mode, this post wasn't credited to your app [bug] so, if you tried to delete it, you couldn't because Facebook only allows to delete posts published by your app.

Unable to retrieve data from facebook graph url for a page

Check out:
https://www.facebook.com/MitraJyothiorg
It is a page of an NGO.
Correspondingly, I should be able to find data of the page in:
http://graph.facebook.com/MitraJyothiorg
This does not seem to work. Any clues?
Please note: I am doing a simple http call and it usually works for other pages, for example, if i do the same thing for another page:teachforindia
The error message is quite clear:
{
"error": {
"message": "Unsupported get request. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api",
"type": "GraphMethodException",
"code": 100
}
}
You need to add at least an App Access Token. See
https://developers.facebook.com/docs/graph-api/reference/page#Reading
For pages that are published, you need:
An app or user access token is needed to view fields from fully public pages.
A user access token is needed to view fields from restricted pages that this person is able to view (such as those restrict to certain demographics like location or age, or those only viewable by Page admins).
A page access token can also be used to view those restricted fields.
I am not able to access that page (get a 404 error). Maybe the page is still hidden? Then you will not be able to access it via the graph API imho.

Getting notifications of managed page using Graph API

Is there any way to get notifications of a managed page just as it can be done for users?
For a user I'd trivially trigger a GET request to /me/notifications. I've tried doing the same for a managed page (using the access token provided by /me/accounts), that is triggering a GET to //notifications?access_token= but I get a "Unsupported get request" error message, which I guess means that the notifications connection is not available for pages.
Is there any way to get this via Graph? The web page has a notifications link/shortcut for each managed page.
Per the graph API Explorer, here are the connections you can access of the page, and unfortunately notifications is not currently on their list:
albums
events
feed
links
notes
photos
posts
questions
statuses
tagged
videos
However, you could try fql?q=
SELECT notification_id, sender_id, title_html, body_html, href
FROM notification
WHERE recipient_id=me()
EDIT
I used a valid PAGE access token and was able to get back data....
{
"data": [
{
"notification_id": "nnnnnnnnnnnn",
"sender_id": nnnnnnnnn,
"title_html": "xxxxxxx posted on Beer's timeline.",
"body_html": "",
"href": "http://www.facebook.com/permalink.php?story_fbid=nnnnnnn&id=nnnnnnnn"
}
]
}