How to find the Facebook ID? [duplicate] - facebook

This question already has an answer here:
Facebook - "Cannot query users by their username" solution
(1 answer)
Closed 7 years ago.
When i go to http://graph.facebook.com/harshamv i get the following error
{
"error": {
"message": "(#803) Cannot query users by their username (harshamv)",
"type": "OAuthException",
"code": 803
}
}
Is there any way i get get my Facebook ID?

You don´t need global IDs anymore, only App Scoped IDs. You get them by authorizing a user with no additional permissions and a call to the /me endpoint.
More about the change can be found in the changelog:
https://developers.facebook.com/docs/apps/changelog#v2_0
More information about the same error message:
Facebook - "Cannot query users by their username" solution
Social framework returns "(#803) Cannot query users by their username (username)" when trying to get user feed
Facebook Graph API v2.1: getting user id and his posts

Related

Facebook friends request returns empty -- despite permissions [duplicate]

This question already has answers here:
Facebook Graph API v2.0+ - /me/friends returns empty, or only friends who also use my application
(8 answers)
Closed 6 years ago.
I'm building a Rails backend for an iOS app. The backend needs to interface with Facebook to grab and use each user's Facebook friends.
But the Facebook 'friends' request is returning empty.
I'm essentially making the following request:
curl https://graph.facebook.com/[FILTERED_USER_ID_FOR_APP]?fields=friends&access_token=[FILTERED]&debug=all
I've looked at a ton of StackOverflow posts about this (this one, and this one, and this one, and more), but haven't found an identical problem or a solution that fits.
I seem to have set permissions correctly. Both on the Rails app and when the user authenticates through the iPhone app, I've set user_friends to be one of the permissions, and, in fact, when someone registers now, it asks them to OK the user friends permission.
But when I actually request their friends, I get a response telling me that there are many friends, but not returning any of them. The below response is for a user who definitely has friends on the app.
{
"data":[],
"summary": {
"total_count": 419
},
"__debug__": {
"messages": [
{
"link": "https:\/\/developers.facebook.com\/docs\/apps\/versions\/",
"message": "No API version was specified. This request defaulted to version v2.7.","type":"warning"
},
{
"link": "https:\/\/developers.facebook.com\/docs\/apps\/changelog#v2_0",
"message": "Only friends who installed this app are returned in API v2.0 and higher. total_count in summary represents the total number of friends, including those who haven't installed the app.",
"type": "info"
}
]
}
}
What's perplexing to me is that a) The App ID/User ID/Access Tokens seem right, because I can get basic profile info, and b) I do not get an error telling me that the request doesn't have the proper permissions. If I make a similar request without permissions on the explorer, it returns a relevant debug note:
{
"message": "The field 'friends' is only accessible on the User object after the user grants the 'user_friends' permission.",
"type": "warning"
}
If I make it with the right permissions in the explorer, it returns a list of friends (in the data array).
So it doesn't seem to be a permissions issue, but the request is returning an empty friends list. Any ideas?
With Igy's help (pointed to this answer), I found the specific answer to my issue, which seems worth adding here.
The problem was that the new 2.0+ API version only returns friends:
Who are on the app
Who have agreed to the user_friends permissions themselves.
1 was all figured out, but because I'm still testing the app out, and nobody had yet accepted permissions, my test user was the only person who had accepted permissions. Nobody else had accepted user_friends, so nobody showed up as a friend of the test user. Getting a friend of the test user to add the permissions fixed the problem, adding that friend to the list of friends returned.

Facebook Graph API privacy setting CUSTOM with allow return error - (#100) Only friends may be specified in allow and deny lists

I am trying to do the following in Facebook Graph Explorer using my app's token.
POST /v2.6/me/live_videos?description=hello%20world&privacy={'value':'CUSTOM','allow':'<friend id>'}&title=welcome
But I am getting the following error, am I doing anything wrong? Should the friend id be app-scoped user id instead?
{
"error": {
   "message": "(#100) Only friends may be specified in allow and deny lists",
    "type": "OAuthException",
    "code": 100,
    "fbtrace_id": "BOcQttKPs5W"
  }
}
The problem here is that you need to know so-called "app scoped user id" of the friend you want to add.

How to get User's avatar after Facebook API was changed

I have an issue the relates with Facebook API. Before, I can use the graph api like that to get user avatar
//graph.facebook.com/giuliana.roeffero/picture?type=large
But now I got this issue
{
"error": {
"message": "(#803) Cannot query users by their username (giuliana.roeffero)",
"type": "OAuthException",
"code": 803
}
}
So now, I need to use the User ID instead of User Name, like this
//graph.facebook.com/100001473111658/picture?type=large
And my question is Can we get the User Avatar by User Name via Facebook API now? If not, how can I get the User Id by User Name?
You can´t get the username at all, it was removed from the API. The only way is to use the (App Scoped) ID, just as you mentioned in your question. So this is how you get the Avatar:
Authorize the User (with no additional permissions) to get his App Scoped ID
use https://graph.facebook.com/[User-ID]/picture to get his Avatar

Very strange - Looks like Facebook Graph does not like alcohol or is permission required? [duplicate]

This question already has answers here:
Graph API returns 'false' or 'Unsupported get request' accessing public Facebook Page
(6 answers)
Closed 8 years ago.
When I go to http://graph.facebook.com/SomePageName ideally it should show info about the page. I was looking for page id of specific pages and found a very strange thing. On checking the following links I get error whereas the pages are in existence:
graph.facebook.com/BacardiIndia
graph.facebook.com/mcdsignature
graph.facebook.com/smirnoffindian
graph.facebook.com/fostersindia
Error below
{
"error": {
"message": "Unsupported get request. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api",
"type": "GraphMethodException",
"code": 100
}
}
Is there any kind of permission required or Facebook does not like indian alcohol :)
Got two more such IDs
https://www.facebook.com/bmwindia
https://www.facebook.com/FranklinTempletonIndia
How can I get their Page Ids?
EDIT: Thanks. It is indeed a question of similar nature. When I tried to find it I could not. Sorry for the inconvenience
It might have to do with age or country restrictions. What is the age and location of the person who's token you are using?

Facebook Graph API OAuthException Code: 9 Access denied. Why?

I am using facebook Graph API to get user data with the below query
https://graph.facebook.com/search?q=xxx yyy zzzz&type=user&access_token=myTokenHere
And the reply is;
{
"error": {
"message": "(#9) Access denied",
"type": "OAuthException",
"code": 9
}
}
And also it makes my account to logoff from developer.facebook.com. When I try refreshing that web site it says I am logged out.
I am used to use this account for making this search, this happened suddenly. I made maybe a thousand successful search with this link, with this user with this query.
It doesn't says I am limited or something.
I googled it a lot and made a lot of research but couldn't find any solution to it.