Facebook graph API: simple search for users by name - facebook

I would like to do a simple search for users by their name from a desktop application using Facebook's graph API. The result I want to have is a list of user names and the link to their profile. I spent several hours reading the documentation but it is still not very clear to me, which access tokens I would need. I have created a developer account on Facebook and added a new app. I've got an app access token and I've tried to do a search using the following URL:
https://graph.facebook.com/search?q=john&access_token={my_app_access_token}
I got the following response:
{
"error": {
"message": "An unknown error has occurred.",
"type": "OAuthException",
"code": 1
}
}
My question now is, if it is possible to do such a simple search without user access token. So the user sitting in front of my desktop application should NOT have to enter his facebook credentials somewhere - never. Can this be done somehow?

When searching, you should provide the search type (in your case user) and to answer your question, no, a user access token is required to search, app tokens won't work for user searches (documented here)

Related

How to get overall star rating of Facebook page from Facebook Graph API?

I am trying to make a very simple request to Facebook's Graph API using this URL:
https://graph.facebook.com/v2.12/1984193321812400?fields=overall_star_rating&access_token=205658113371329|gYdP-nDHNVENlwVxria21Uczgs8
All I want from Facebook is the overall_star_rating of my Facebook page. However, this is what I get:
{
"error": {
"message": "(#200) Access to this data is temporarily disabled for non-active apps or apps that have not recently accessed this data due to changes we are making to the Facebook Platform. https://developers.facebook.com/status/issues/206742313468873/",
"type": "OAuthException",
"code": 200,
"fbtrace_id": "A9XRfTkh3WR"
}
}
Since I am completely new to Facebook Graph API: Is the request I am making correct or am I missing something really fundamental here?
And yes, I read Facebook's issue report, but I don't find it very helpful since I set my app to active already and it's not working anyway.
Thanks for any help in this matter.
Since Facebook is undergoing major changes, they have revoked few access to non active apps. Get the access_token from any frequently used app, your Graph API call is pretty correct!
But the Page ID seems to be wrong, as it shows me error after adding a working token.
Error : "message": "(#803) Some of the aliases you requested do not
exist: 1984192327815400"
After changing the Page ID, and adding active app token, it shows the correct result.

Facebook app token not working, but access token works

I have a really weird situation here, and I've looked everywhere through Facebook's documentation with no answers.
I'm trying to get get recent posts from multiple Facebook pages. But one of them keeps crashing. It won't work when I'm using an app token. It works if I'm using access tokens, but those expire, so it'd be better to not use that.
https://graph.facebook.com/norgeshushonefoss/posts?access_token=myAppToken
gives this result:
{
"error": {
"message": "Unsupported get request. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api",
"type": "GraphMethodException",
"code": 100
}
}
While this url gives me the recent posts: https://graph.facebook.com/norgeshus/posts?access_token=myAppToken
I can't see any difference in those two. Are there any page settings that may cause an app token not to authorize for some reason?
If the page has any access restrictions in place (age, location, alcohol-related content), then you can not access any of its info using your app access token.
It needs a user access token for a user that qualifies to see the page (or a page access token).

Facebook Graph API "/{page-id}/feed" is not working with App Access Token

We are facing issues with Graph API. The Facebook Graph API "/{page-id}/feed" is not working for all pages with a valid App Access Token. Previously it used to work. We noticed it today the API is throwing error
{
"error": {
"message": "An unknown error has occurred.",
"type": "OAuthException",
"code": 1
}
}
Not working pages:
https://graph.facebook.com/22934684677/feed?access_token=
https://graph.facebook.com/42798291365/feed?access_token=
Note: And its working if we pass a User Access token instead of App Token.
Facebook developer Docs says "An access token is required to view publicly shared posts." So App Access Token should work!
Does Facebook change something inside the API?. Can any one help to solve the issue
You should use a Page Token for Page data. Pages not working with an App Token are most likely restricted by age or location. Since the App Token does not include any user session, you canĀ“t be sure if the user should have access to it.
If it does not work with an App Token AND the Page is definitely not restricted, file a bug.
This is happening because some of the posts returned might have extra restrictions on them which need a user token to verify this. Use a page token or a user token as a workaround for this. Having said that, the request shouldn't fail with an unknown error and we're working on a fix for the same on the bug report here:
https://developers.facebook.com/bugs/783169051760311/

How to Get feed of public Facebook page using Graph api?

There are already several questions on StackOverflow ( Can you get a public Facebook page's feed using Graph API without asking a user to allow? Get public page statuses using Facebook Graph API without Access Token? )concerning my question: I need to get through the graph API the feeds of a public page on facebook.
I followed the instructions but I always get:
{"Error": {"message": "An access token is required to request this resource.", "Type": "OAuthException", "code": 104}}
how can I fix this? I'm going crazy because everyone seems to work except me! thanks
Based on your description, the error is that you weren't supplying a valid access token with your request.
If the app's type is set to 'Native / Desktop' it's assumed you distributed the app's secret key with the binary, and thus the app access token isn't trusted (and 'getAccessToken' in the PHP SDK will only work when real users log in, it can't fall back to the app token)
If you were attempting to use the app access token to read the page's feed, this would fail in the manner you described.

Facebook Graph API...how to get started?

Hi I'm trying to get a JSON file about the list of the friends of Bret Taylor ("btaylor" is a profile of Facebook used for practice). I am reading the Graph API official guide (on FB website) and I am undesrtanding that for this request I need an authorization token code.
I've found an access token code from the link
https://graph.facebook.com/oauth/access_token?
client_id=YOUR_APP_ID&client_secret=YOUR_APP_SECRET&
grant_type=client_credentials
where I've wrote my aps id and secret code but if I try to open the following URL using the access token code
https://graph.facebook.com/btaylor/friends?access_token=MY_TOKE_AUTH_CODE
I get the following error message:
{
"error": {
"message": "(#604) Can't lookup all friends of 220439. Can only lookup for the logged in user (0), or friends of the logged in user with the appropriate permission",
"type": "OAuthException"
}
}
the token code is something like access_token=112701417077438|GnwE4LeR_f_3r-mmxoi79ukgEFd
Where is the problem? With Google I've found some tutorial with long php pages but following the official guide I can't understand how to use all of this code...on the official guide everything appear extrimely short and easy...
First things first, you need to set up your Facebook application. Go to the Developer App:
https://developers.facebook.com/apps
During the process, you will get an App ID and an App Secret. Take note of them.
What to need to do next depends on the type of app you want to create, either a web app or a app on Facebook. You speak about Access Tokens, so I guess you want to create a web app.
Steps are here, it's pretty easy:
http://developers.facebook.com/docs/guides/web/#login
You will need the infos gathered on the first step.