Getting User Birthday HTTP Request - facebook

Im trying to get birthday on the server side of my app.
I have already the ["user_birthday"] permission on my login request.
But now on the server i need to do something like this i guess.
userBirtdhay = "https://graph.facebook.com/me?fields=birthday&" + user.services.facebook.id;
But this results something like.
https://graph.facebook.com/me?fields=birthday&10146450841965723dffsadf
And if you go to the url you get a
{
"error": {
"message": "An active access token must be used to query information about the current user.",
"type": "OAuthException",
"code": 2500
}
}
After Some research got that the me space on the url should be my accessToken so i try with .
https://graph.facebook.com/longAccesToken?fields=birthday&
But it returns now.
"message": "(#803) Some of the aliases you requested do not exist:

This would be correct:
https://graph.facebook.com/me?fields=birthday&access_token=[your-user-token]
You should start reading the Facebook docs about Access Tokens and API endpoints. You can test the API with the API Explorer.

Related

An accessToken issue using the Graph API

I'm trying to make a GET request from the Facebook Graph API, graph.facebook.com (using Postman, a Chrome application) to get all events containing the key word as below:
graph.facebook.com/v2.8/search?pretty=0&q=<MY_CITY>&type=event&accessToken=<MY_APP_ACCESS_TOKEN>
I'm having this response from Facebook:
{
"error": {
"message": "An access token is required to request this resource.",
"type": "OAuthException",
"code": 104,
"fbtrace_id": "B5KWVqr7ajK"
}
}
I've rechecked my app_access_Token, and it's fine and works for other requests. How can I fix this problem?
https://developers.facebook.com/docs/graph-api/using-graph-api/#search:
All Graph API search queries require an access token included in the request. You need a user access token to execute a search.

Facebook Open Graph event search

On Graph API Explorer I can do this search: search?q=Barcelona&type=event
But when I try the same with my app access token I get this error:
{
"error": {
"message": "(#200) Must have a valid access_token to access this endpoint",
"type": "OAuthException",
"code": 200
}
}
The other searches work well.
UPDATE 2017-11-27:
As Facebook doesn't allow an event search based on location anymore, I'd recommend to use https://github.com/tobilg/facebook-events-by-location-core
Original answer:
Please refer to https://developers.facebook.com/docs/reference/api/search/#access_tokens
There, it's stated that all searches except for pages and places require an user access token.

FB Graph API: Get id of a page with a country restriction

Is it possible to get the Page ID of a page that has country restrictions?
Usually if I do something like http://graph.facebook.com/google
I'll get a response object with a bunch of info (incl. the id).
However doing http://graph.facebook.com/[page_with_country_restriction] returns:
{
"error": {
"message": "Unsupported get request.",
"type": "GraphMethodException",
"code": 100
}
}
Yes. It's possible to get the information of a page with country restrictions. You just need a valid Access Token for that.
Try making a request to the URL using that Access Token. Something like:
https://graph.facebook.com/teabeauty?access_token={Access_Token}
You can always make use of Graph API Explorer to test your requests and queries.

Facebook: How to set app test users as friends?

1) I try to get an access token for my app as described in the docs:
To obtain an App Access Token, invoke the following HTTP GET request
GET https://graph.facebook.com/oauth/access_token?
client_id=YOUR_APP_ID
&client_secret=YOUR_APP_SECRET
&grant_type=client_credentials
The API will respond with a query-string formatted string of the form:
access_token=YOUR_APP_ACCESS_TOKEN
I get an access token with a strange splitter sign | as a result:
access_token=568852943149232|ah1X8cAXHKSvFrTrZ4XybG0GzR4
This seems to be in a conflict with the docs, because the first parameter is app_id (before the sign |).
2) Then I try to use the strange access_token to get friend's access tokens (it requires to make invisible test users friends):
https://graph.facebook.com/APP_ID/accounts/test-users?access_token=568852943149232|ah1X8cAXHKSvFrTrZ4XybG0GzR4
It returns:
{
"error": {
"message": "(#803) Some of the aliases you requested do not exist: APP_ID",
"type": "OAuthException",
"code": 803
}
}
If I remove the part before | (including the sign |) and make another request it returns another error:
{
"error": {
"message": "Invalid OAuth access token.",
"type": "OAuthException",
"code": 190
}
}
3) In result I need to make a 'friend' request from one user and response from another (described here):
https://graph.facebook.com/USER1_ID/friends/USER2_ID?method=post&access_token=TEST_USER_1_ACCESS_TOKEN
https://graph.facebook.com/USER2_ID/friends/USER1_ID?method=post&access_token=TEST_USER_2_ACCESS_TOKEN
I can't do that because I can't get these (users') access tokens on the step 2.
Is returning app access_token correct? If yes, how to use it?
Notice please: I make the calls from an address line of a browser, app owner in a logged-in state.
You need to replace APP_ID with your actual APP_ID
That's why you get this message.
{
"error": {
"message": "(#803) Some of the aliases you requested do not exist: APP_ID",
"type": "OAuthException",
"code": 803
}
}
If your app id is 568852943149232 and your app token is 568852943149232|ah1X8cAXHKSvFrTrZ4XybG0GzR4 then your call is
https://graph.facebook.com/568852943149232/accounts/test-users?access_token=568852943149232|ah1X8cAXHKSvFrTrZ4XybG0GzR4
That is indeed your app token easily verifiable by https://developers.facebook.com/tools/access_token

Search for places with an App Access Token suddenly stopped working

i am calling the graph API with an App Access token (grant_type=client_credentials) to search for places on facebook. Quering for
https://graph.facebook.com/search?type=place&center=50.785361,6.0334127
Used return the search result reliably but suddenly stopped working with the following error:
{
"error": {
"message": "An unknown error has occurred.",
"type": "OAuthException",
"code": 1
}
}
I have tested the call on the Graph API Explorer. With my facebook user's access token the request still returns the desired data. Other requests with this app access token still work, so the token is good.
Any ideas?