How to get information from page facebook api graph - facebook

I have two examples:
Example 1:
https://www.facebook.com/cocacola
I get "likes","description" at https://graph.facebook.com/cocacola/
It work.
Example 2:
https://www.facebook.com/selectivefitness
I get errors at https://graph.facebook.com/selectivefitness/
Why example 2 does not working? How i can get "likes" "description" of https://www.facebook.com/selectivefitness

It's because of restrictions on the page (either country restrictions or age restriction). You just need a valid Access Token to fix it.
Try making a request to the URL using that Access Token. Something like:
https://graph.facebook.com/selectivefitness?access_token={Access_Token}
You can always make use of Graph API Explorer to test your requests and queries.

Related

Searching public profiles using Facebook Graph API

I am looking to search Facebook public profiles using the Graph API with parameters like name, location and age. To accomplish this I created a Facebook app to get an app ID but I am unsure as to how to proceed to make the query to the API.
To try it out I tried using the explorer (https://developers.facebook.com/tools/explorer/) but I am unable to get any results that does not contain "me". I made sure to get a access token and enter a query like the following:
search?q=tobias&type=user&fields=id,name
The only reply is:
{
"data": [
]
}
I feel like I am missing something but I have been unable to figure out what, please advice.
The search endpoint is broken since 2018-04-04 for certain search types, including pages and users.
Search API
You can no longer use the /search endpoint with the following object types:
event
group
page
user
See
https://developers.facebook.com/docs/graph-api/changelog/breaking-changes#search-4-4
Due to what has recently been in the news, searching for users has been deprecated, and is not supported through Facebook APIs.

facebook test user no graph API search place result

I have created a test user for my app under development (not public yet), and using the access token generated for the test user to call graph API.
The graph API I am trying is search place (/search type=place distance=1000).
And I specify my current location as parameter.
However, I only get the following data in return:
{"data":[]}
If I specify distance=10000, I get a few place names, but this result is totally different from my result with ordinal (non-tester) user.
Using access token for non-test-user, I get 100s or more place names.
Question:
Why this difference?
Any setting needed for test user creation so that its graph API search result is the same as the ordinal user's?
(In case it is a limitation of test user, how I can test an app which use graph API, with a test user?)
Any help or clue is highly appreciated!

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.

How to get Facebook page total likes number with the new Graph API (v2.4)

So recently there was a update to the Facebook Graph API and now pretty much everything requires a access_token to retrieve any type of data.
Previously you could get the number of page likes by accessing the graph like so:
http://graph.facebook.com/{page-name}
But now if you try it says you need to have a access token because of a recent update to the API. Now the issue i am having is i cant access the likes even with an access token this is the response i am getting:
Request
http://graph.facebook.com/{page-name}/?access_token={access_token}
Response
array(2) {
["name"] "Page Name"
["id"] "Page Id"
}
Now at first i thought the access token wasn't being generated with the correct scopes but i am 99% sure you only need read_stream to pull that type of data.
Second thought is that they have removed the ability to acces likes of any page and you need a page token to receive that type of data or finally i am missing something incredibly small here and its still achievable?
So my question is can you still get the number of likes of any page using the Facebook Graph API and if the answer is yes how do you do it?
any help appreciated
This can help you! Just add ?fields=likes after the page name/id. You can use any access token for fetching data!
graph.facebook.com/{page_name}?fields=likes&access_token={token}
The Graph API v2.4 reduces the number of fields in default responses.
https://developers.facebook.com/blog/post/2015/07/08/graph-api-v2.4/
Fewer default fields for faster performance: To help improve performance on mobile network connections, we've reduced the number of fields that the API returns by default. You should now use the ?fields=field1,field2 syntax to declare all the fields you want the API to return.
If you do ?fields=likes it should show up.
You can do like this:
https://graph.facebook.com/v2.4/{page_id}/fields=likes

Understanding Facebook Graph API identifiers

While I do realize that the ids for graph api objects are not documented, I'm seeing some oddities which I'd like to understand.
I have an authorized app that polls a page's feed for new comments and it looks like I'm getting different ids for the same post.
On first run I get a post with the id of:
1470990656482896_1553567768225184
Which is the id of the page and post joined by an underscore.
The second poll which ran a few minutes later, I received the same post with a different id:
100008124617959_1553567768225184
Which is the user id of the poster and post joined by an underscore.
While I'd like to understand the inconsistency, the real problem is trying to access the post via the second identifier returns an Unsupported get request with the code of 100
The post is public and is accessible via both
https://www.facebook.com/100008124617959/posts/1553567768225184
and
https://www.facebook.com/1470990656482896/posts/1553567768225184
This sounds like an oauth problem. While the post is public, to access it via the graph API you have to use an access token.
If you use the access token for Hans Gotwo then you should be able to access the post with the id of 100008124617959_1553567768225184
Looks like it's a bug. thanks #phwd
https://developers.facebook.com/bugs/721538487964698/