Is there a way to get the location/hometown (whichever available) using the facebook graph API?
The catch here is I do not want the user to go through an authentication process, meaning I want to get the location/hometown without having the access_token
Therefore, the following case would be void
https://graph.facebook.com/USERID?fields=location,hometown&access_token=USER_ACCESS_TOKEN
Please help
Regards
access token is required with the following permissions
user_hometown
user_location
use hometown_location field of a user table to get location details. We get this info. only if a user shares it's location detail public.
If you have the permissions to access this user data, you just have to parse the key-value dict to your model, eg:
self.user.location = [user objectForKey:#"location"][#"name"];
same for hometown:
self.user.hometown = [user objectForKey:#"hometown"][#"name"];
Regards.
Related
I need to get the userid of the person who creates the post, and based on the documentation: https://developers.facebook.com/docs/graph-api/reference/v2.9/post#read
This information is in the admin_creator field. Example: {post-id}?fields=admin_creator I am already the admin of the page and manage_pages permission, so I dont understand what is going on... Thanks!
you must be an administrator for the page.
{post-id} must be a scoped id.
like this : 618683548311391_851244161721994
https://graph.facebook.com/v2.9/{page_id}/posts?fields=admin_creator&access_token={page_access_token}
PS: This endpoint requires an access_token from the page
I have the following rest url:
facebook.com/4?fields=about,birthday,education,bio,age_range,email,first_name,gender
I don't understand why it shows only the name and id? I thought that those fields are public, or am I wrong ?
Thanks
No, of course you have to get permission from the user before getting any data: https://developers.facebook.com/docs/facebook-login/permissions
"Public" does not mean you can grab everything with an App. And you should always use /me instead of /user-id. /me points to the authorized user, there is no need to use the id.
So in order to get the insight data for my application I need the access_token with read_insight_data permission. However I don't want a user interaction during the process. Can I get my application's insight data with just application ID and secret?
thanks,
Green
Okay I got it.
First, get client(AKA application) access token:
https://graph.facebook.com/oauth/access_token?client_id=${client_id}&client_secret=${client_secret}&grant_type=client_credentials
facebook will return something looks like:
access_token=XXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Second Use that returned token you can get the application insight data:
https://graph.facebook.com/${client_id}/insights/?access_token=XXXXXXXXXXXXXXXXXXXXXXXXX
I want to get the statistics of all the pages associated with my account on facebook, i have the code to get the statistics of a page, i just want to get the page id of all the pages associated with my account, how can i do this?
Please help.
Thanks.
You'll need to request the manage_pages permission (more details here), once you have the aquired the permission, all you have to do is make a request to :
https://graph.facebook.com/YOUR_FACEBOOK_ID/accounts.
The return value will be a JSON with all the pages/applications that are associated with your account.
You can also use this great tool that facebook provides - The Graph API Explorer (/me/accounts) to explore what other information you can retrieve without having to write a single line of code :P very useful.
FB.api('/me/accounts', function(response) {
for (id in response.data)
{
page = data[id];
page.id;
page.name;
}
});
You can use Javascript API to do this, read more :http://developers.facebook.com/docs/reference/javascript/
I'm trying to figure out how to get users friends information using either Graph API or FQL
Just for testing I would like to get my friends education_histroy.
To do that I created a test app, requested extended permissions using
scope=offline_access,manage_friendlists,friends_work_history,
friends_education_history,friends_about_me
and got access token to play with the API.
It works great when I query for current user using /me. But it returns nothing for my friends.
I was assuming that if I request, let's say friends_work_history, that extra field (work_history) will appear inside friend's object, when I query by friend's id:
https://graph.facebook.com/FRIEND_ID&access_token=TOKEN
But all I see is basic info about that user (friend).
Then I tried to request that field specifically:
https://graph.facebook.com/FRIEND_ID?fields=work&access_token=TOKEN
With no luck again. Returns just friend's id..
I tried to access that information with FQL:
https://api.facebook.com/method/fql.query?query=select+work_history+from+user+where+uid+in+(FRIEND_ID)&access_token=TOKEN
Returns work_history = TRUE instead of array. And that friend definitely has work history specified.
Can someone help me to understand how to get friends info using my app and extended permissions?
Graph API is the smart choice in most cases. To retrieve your friend information you need to collect some extended permissions from the user first. Then you can retrieve a lot more information other than the basic ones.
Following is a list of extended permissions related to friends different kind of information
friends_about_me
friends_activities
friends_birthday
friends_checkins
friends_education_history
friends_events
friends_games_activity
friends_groups
friends_hometown
friends_interests
friends_likes
friends_location
friends_notes
friends_online_presence
friends_photo_video_tags
friends_photos
friends_relationship_details
friends_relationships
friends_religion_politics
friends_status
friends_subscriptions
friends_videos
friends_website
friends_work_history
Hope it helps :)
I've been wrestling with this all day myself and I believe I have figured it out, nowhere in facebook documentation (that I have found) is this clear. And I don't believe the other answers actually answered your question, it looks like you requested permissions correctly. Anyway, to request the information you are looking for, ping the api like this:
https://graph.facebook.com/userid/friends?fields=work&access_token=ACCESSTOKENHERE
This will return you all the friends' info in one long JSON response.
It is a little confusing because the permissions you are asking for are not the same thing you need to query the API.
The query above will return the friends' ids with work history. You can add commas to the fields parameter to include additional info like name, but then the API calls/responses end up taking a long time.
http://developers.facebook.com/docs/reference/api/user/
you can get all the fields mentioned here .To get work you need to have user_work_history or friends_work_history permission
in the link it is mentioned what permissions to obtain before you get the info and another thing that user has to allow your application,this will make your app to get the informations.
From this answer to another question: a call to 'me/friends?fields=work' worked for me!
I'd suggest that you go to http://developers.facebook.com/docs/reference/api/user/ like most of the others are suggesting but as a general tip, use the friends_education_history as a way to get the friend's history.
P.S: Minor spelling error in your original question that should be edited. "education_histroy." = education_history
in the second line of your main paragraph.
You can use this code you will get name, profile picture, ID of your friends.
FB.api('/me/taggable_friends', function(response) {
for (var i = 0; i < friend_data.length; i++) {
results += ''+friend_data[i].name;
}
});
Before that in your developer account created app-> go to tools and support->graph API explorer-> click Get Token. In that window click user_tagged_places and click Get Access Token. You will get your friends list.