Facebook: How to set app test users as friends? - facebook

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

Related

App access token, can't get user information

When I try to use the already generated access token, on this https://graph.facebook.com/4921782178422?fields=id&access_token=ACCESS_TOKEN, it gives me this in response:
{
"error": {
"message": "Unsupported get request. Object with ID '4921782178422' does not exist, cannot be loaded due to missing permissions, or does not support this operation. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api",
"type": "GraphMethodException",
"code": 100,
"fbtrace_id": "F2ot2MGcBBM"
}
}
Facebook writes that all access tokens have permissions to public_profile, but i can't use the link above.
4921782178422 is a user id.
It works fine, when I use my own user access token, but that's only valid for 1 hour, and I need it longer than that.
I have followed these steps:
facebook: permanent Page Access Token?
What do I do wrong?

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.

Getting User Birthday HTTP Request

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.

Facebook Graph Explorer Error Code 100 (OAuthException)

So I am inputting my correct access token and the correct ID, and when I use GET, it returns this error.
{
"error": {
"message": "(#100) Requires user session",
"type": "OAuthException",
"code": 100
}
}
When I use Get Access Token to get a test token, it returns the correct information. Why is this happening?

Graph API delete all scores

As stated in the Scores API documentation:
You can delete all the scores for your app by issuing an HTTP DELETE request to /APP_ID/scores with the app access_token for that app. This will reset the scores for your app. Use this if you'd like to periodically reset your game's scores and leaderboards.
So I go to Graph API Explorer and type /(APP ID OMITTED)/scores, Select DELETE method and paste in the app token I get from Access Token Tool in the access token field. I click submit and the following error is displayed:
"error": {
"message": "An unknown error has occurred.",
"type": "OAuthException",
"code": 1
}
If I paste in the user's token ID instead I get this:
"error": {
"message": "(#15) This method must be called with an app access_token.",
"type": "OAuthException",
"code": 15
}
What am I doing wrong?