Getting Public Info about Location in Facebook Graph API - facebook

I need to get the living city of each person in a group. Including people that are not my friends.
In the browser seeing facebook profile of some unknown person, they show "lives in ...", if this is set as public information. They include the link to the city object with the city id in the link. That's all that I need.
But, using a facebook app that I created to use the facebook graph api, this information is not public. I can only get the user propriety 'location' from friends of my that I have permission to see it. I gave ALL the possible permissions to my app.
In the api explorer, when I use it as REST, they show few informations about someone not friend of mine.
https://developers.facebook.com/tools/explorer/
Also in the api explorer, when I use the FQL, it didn't works.
This query works, returning the JSON with the data:
SELECT uid, name FROM user WHERE username='...';
But this other query doesn't work:
SELECT uid, name, location FROM user WHERE username='...';
They return a json with a error code:
{
"error": {
"message": "(#602) location is not a member of the user table.",
"type": "OAuthException",
"code": 602
}
}
I asked for ALL the permissions options in the token. And I can get this info in the browser version of the facebook. But how can I get it with the API ?

The location field only exists in the Graph API table. Since you are using FQL, here are the location fields available to you:
current_address: the current address of the user,
current_location: the user's current location,
hometown_location: the user's hometown (and state).
Permissions:
user_location or friends_location permissions to view: current_location,
user_hometown or friends_hometown permissions to view: hometown_location.
Source: https://developers.facebook.com/docs/reference/fql/user/

Related

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

How can I get user's facebook interests?

I am trying to get interest from Facebook Api but empty array is returned.
I have searched for other issues like:
How to get user Interests? (//stackoverflow.com/questions/12422714/how-to-get-user-interests)
How can I get the interests of my friend through facebook api?(//stackoverflow.com/questions/6587373/how-can-i-get-the-interests-of-my-friend-through-facebook-api)
In "Graph API Reference" (developers.facebook.com/docs/graph-api/reference/v2.1) is defined a full list of nodes. If I click in 'user' and click in 'interest' I am redirected to "/{user-id}/interests" (//developers.facebook.com/docs/graph-api/reference/v2.1/user/interests) description. In this description are defined serveral points:
Endpoint: GET /user/interests
Permission: user_interests
Descrption: The interests listed on someone's profile under "Likes > Interests" (//www.facebook.com/me/likes_interests).
I am using Graph API Explorer for to test. I have used all api versions (from unversioned to v2.1).
If I get a valid access token with aproppiated permission and I do a request to endpoint "/me" I have a successfully response with data.
If I do a request to endpoint "/me/interests" I have a empty response:
{
"data": [
]
}
My user in Facebook is following a list of interest for example: stackoverflow group.
If I do a request to movies or books the response are empty too. But if I do a "like action" in a book or movie and try again I have a successfull response. If I try again with "/me/interest" response is empty yet.
I believe that I do not understand concept of "interest" or something is wrong and I can not see it.
Which is the way for to recovery the interests of an user?
The interests are specified in the Profile section, and not via Like actions! The list you linked is not an interest either.
Books and Movies can be requested with the user_likes permission, so if you didn't request that the response will be empty as well.

Facebook interested in {gender} returns null

I'm trying to list all my friend's gender interests, the "Interested in women" for example.
The scope of my token is basic_info, friends_relationship_details, friends_relationships, public_profile, user_friends, user_relationship_details, user_relationships.
The user_relationship_details correctly allowed me to see my own "interested in" field, but friends_relationship_details did not do the same for my friends. They all return null.
Full query in fql is "SELECT uid, name, meeting_for, meeting_sex, relationship_status FROM user WHERE uid='{friend-uid}'"
I have also tried OpenGraph Explorer with my app's access token and interested_in doesn't show up there either.
Why would this be?
update: Even if a friend has interested in privacy as public, my app can't access it.

FQL query in Graph API explorer not returning all of the data in profile

I have created a test user for my facebook app and filled in the fields for name, profile picture, music, tv, movies, books, actvities and interests. The information is there and I can view it in the profile, but for some reasons in spite of having specified what appear to be the correct permissions, I cannot access this information even through the Grap API explorer when I am logged in as the user.
When I go to the Graph API explorer, go to the FQL tab and launch the following query I only get certain fields:
SELECT name,pic_big,music,tv,movies,books,email FROM user WHERE uid = me()
The response is:
{
"data": [
{
"name": "Aisha Bibi",
"pic_big": "http://profile.ak.fbcdn.net/hprofile-ak-snc4/274348_100004159483336_574477135_n.jpg",
"music": "",
"tv": "",
"movies": "",
"books": "",
"email": "aisha_gjmodrm_bibi#tfbnw.net"
}
]
}
I generated the access token for this request by selecting the following user data permissions: email, user_activities, user_education_history, user_interests.
Could anybody tell me why it is failing to retrieve information for the user even though it is present on the profile, I have detailed the correct permissions(?) and I am logged in as them while accessing the Graph API explorer tool?
Thanks in advance :D
I am sorry - I did not read the documentation clearly enough it seems. In order to access the user's music and movies etc you need the user_likes permission. I hope this helps somebody!

HTTP 400 Error when accessing Friends list in Facebook Graph API

When I access the list of my friends using the URL https://graph.facebook.com/me/friends?access_token=... I can see the list of my friends. I can do this programmatically as well.
Now, when I take the ID of any of my friends and replace it with "me" in the above URL, and paste the URL in the browser, I can see my friend's friends. I am unable to do this programmatically because it is giving me an HTTP 400 ERROR.
Does anyone know why this is possible by pasting the URL and not programmatically?
You can not get the "friends of friends" using the facebook api.
For example, try the simple /me/friends with the Graph API Explorer, it should work fine.
Then, take one of the ids there and try the same with FRIEND_ID/friends and you should get this:
{
"error": {
"message": "(#604) Can't lookup all friends of FRIEN_ID. Can only lookup for the logged in user or the logged in user's friends that are users of your app.",
"type": "OAuthException",
"code": 604
}
}
The error itself is very straight forward and explains exactly what the problem is.
As for why that translates into a 400 error code for you is unclear.
Edit
You can't see the "friends of friends" in the browser as well, the reason that it works for you (probably) is that the user(s) you check the friends for (USER_ID/friends) installed the app that the access token belongs to, from the way you got to that url I assume that the app is the "Test_console".
How to check? Copy the access token from the url (USER_ID/friends?access_token=xxxxx), go to the Facebook Debugger and paste the token in the text field and click "Debug", it will show you info regarding the application.
The user you checked it for probably has that app "installed", if you check it for other users you will get that error when you get to a user who does not have that app "installed".
I hope this clarifies it for you.
I got friends of friends(limited) who are using application. I had same problem. Though it is very late for answering question, it will help somebody. That's why answering this question.
We can get friends of friends those are app users.
$fb_id= user id whose friends of friends required.
Try this fql query.
$query="SELECT uid, name, work_history FROM user WHERE uid IN (SELECT
uid2 FROM friend WHERE uid1 IN (SELECT uid FROM user WHERE uid IN
(SELECT uid2 FROM friend WHERE uid1 = $fb_id ) and is_app_user=1) )";
It needs following requirements:
Your friend needs to be using application.
Permission from application read_stream, publish_stream, publish_checkins.