I am trying to get the Facebook UID's of results returned from a Social Graph search. For example, lets say I were to search "People who like surfing and live in Florida" I would then want to grab the Facebook UIDs of all of these search results.
I can do this one at a time by opening each person's profile and entering their profiles URL into a site like findmyfacebookid.com.
I am just hoping there is a quicker way to do this. Does anyone have any ideas on where I might start? Thank you all!
For getting userid's you may use graph API calls.There isnt any need for an external website.
Use this API request,
http://graph.facebook.com/{USERNAME} OR {USERID}
Eg: http://graph.facebook.com/mark
And you will get a result set of basic profile parameters in a JSON format.
{
"id": "4",
"name": "Mark Zuckerberg",
"first_name": "Mark",
"last_name": "Zuckerberg",
"link": "http://www.facebook.com/zuck",
"username": "zuck",
"gender": "male",
"locale": "en_US"
}
Related
I have a "Like"-object data from facebook:
{
"name": "24",
"category": "Tv show",
"id": "14176232250",
"created_time": "2010-10-29T17:46:27+0000"
}
it's possible to get all users, which have that "object" in their "likes"?
It is not possible to retrieve information on users who like a page via either the Graph API or FQL.
See this previous question: Retrieve Facebook Fan Names
We're working on developing a program that will (hopefully) automatically swap out creative with new creative once a certain like threshold is met (i.e. if 100 people like the page, something new appears). Can we add coding so our system is able to tell how many "likes" are generated? I know that the number of likes are displayed, I'm just not sure if there is a way for a program to actually read how many likes there are.
I don't see if in any of the Facebook attributes in the developer's platform.
What you'll have to do is acquire an access token for your page and then query the facebook platform for the number of likes periodically (possibly with a cron job of sorts).
You can read more about how to get the page access token at this URL
https://developers.facebook.com/docs/authentication/
Facebook has given us a great took to help us mine all the data it holds - its called the Graph API Explorer and with it you can see what data will be returned when you query the API. When you query the API with only the page_id you'll get a response similar to this :
{
"id": "XXXXXXXXX",
"name": "My Awesome Page",
"picture": "foo.jpg",
"link": "https://www.facebook.com/pages/XXXXXXXX",
"likes": 345,
"category": "Product/service",
"website": "XXXXXXX",
"founded": "2011",
"description": "...",
}
For more information about how to use the Graph API you can see this link :
https://developers.facebook.com/docs/reference/api/
Facebook does provide good documentation:
http://developers.facebook.com/docs/reference/api/page/
As you can see there, there is a field "likes" containing the number (count) of likes for a page.
I'm writing an app which requires me to determine whether I show the fb "like" button or not. fb profiles don't have "likes" but pages do. any recommendations on how I can programatically differentiate between a fb profile and a fb page? the only input i get from the user is the fb profile/page URL and based on that I need to determine whether its a page or a profile and then display the like button.
thx,
Yes, you can look at the type attribute of the returned JSON. For example, take a look at actual, redacted Graph API responses that I receive for a user and a page:
//This is JSON for a user
//Call to https://graph.facebook.com/123456789
{
"id": "123456789",
"name": "Sean Hill",
"first_name": "Sean",
"last_name": "Hill",
//more attributes
"type": "user" // <--- This one
}
vs
//This is JSON for a page
//Call to https://graph.facebook.com/thesolusean
{
"id": "323796444951",
"name": "Solusean",
"picture": "https://fbcdn-profile-a.akamaihd.net/hprofile-ak-snc4/50290_323796444951_3601170_s.jpg",
"link": "https://www.facebook.com/thesolusean",
"likes": 28,
// more attributes
"type": "page" // <---- This one
}
Without knowing which programming language you're using, this is the best answer I can give.
So far it seems the only quick way to know whether given profile is page or actual user is by looking at category attribute. If this attribute is present then its a page otherwise it could be user. FB reference docs doesn't seem to have any clear guidance (see https://developers.facebook.com/docs/graph-api/reference/profile). In additional most of the APIs that return profile as part of other response only includes partial information of id, name and category:
"from": {
"category": "Magazine",
"name": "Astronomy Magazine",
"id": "108218329601"
},
Note: I'm confused by #Sean Hill's answer. There is no type attribute in profile objects.
I am developing a social media monitoring service. And I'm now trying to fetch the posts and comments from a certain group of users.
However, I found that a lot of empty posts are fetched by Graph API https://graph.facebook.com/somebodysuid/posts?access_token=xxxx . That is, a lot of posts are of the following form:
`{
"id": "somebodysuid_xxxxxxxxxxxx",
"from": {
"name": "XXX YYY AAA",
"id": "somebodysuid"
},
"type": "status",
"created_time": "2011-08-03T05:49:11+0000",
"updated_time": "2011-08-03T05:49:11+0000",
"comments": {
"count": 0
}
},
{
"id": "somebodysuid_yyyyyyyyyyyyyyy",
"from": {
"name": "XXX YYY AAA",
"id": "somebodysuid"
},
"type": "status",
"created_time": "2011-07-24T23:31:35+0000",
"updated_time": "2011-07-24T23:31:35+0000",
"comments": {
"count": 0
}
},
Through these are indeed posts, but they're totally useless. The worst thing is, half of the data I fetched are of this kind....
Can somebody please explain why so many empty posts would the API fetch? Can this be solve by any way?
Those posts are probably updates made through the "new share form" where users can tag places and friends and attach geo-locations without adding any additional message.
Those type of posts are typed as "status" but graph api does not return the other meta-datas yet (location, tags, etc...) that's why you see them empty.
Let's hope FB will fix that quickly :(
I think FB has started to add activity information that appears on a Facebook web page, such as "John Doe is now friends with Tom Jones", or "Fred Smith and 2 others have changed their profile image". This activity information is a) incomplete in the returned feed and b) does odd things when you look for more information by asking the graph API for detail based on the posts id field.
My current guess is that this is new functionality for the feed - I have been unable to find documentation or mention of it. They are very difficult to process at this time, since they look like other things and contain no identifying detail.
Here is the question I posted looking for help. It give another example:
Facebook graph "user/home" feed now contains activities as post items that are difficult to identify
Given a facebook url such as http://facebook.com/cnn, is there any way to get the ID of that page short of scraping it?
It is better (and legal) to do this with graph API. Just perform API request to https://graph.facebook.com/cnn and get id from the response.
Here is the response for cnn:
{
"id": "5550296508",
"name": "CNN",
"picture": "http://profile.ak.fbcdn.net/hprofile-ak-snc4/hs178.ash2/41813_5550296508_728_s.jpg",
"link": "http://www.facebook.com/cnn",
"category": "Company",
"website": "www.cnn.com\nwww.ireport.com\n",
"username": "cnn",
"company_overview": "TRIVIA FROM THE CNN TOUR...",
"products": "CNN US...",
"likes": 1689936
}
Facebook's own Graph API supports it. From the documentation:
The "ids" query parameter also accepts URLs. This is useful for
finding IDs of URLs in the Open Graph. For example:
https://graph.facebook.com/?ids=http://www.imdb.com/title/tt0117500/
As of Today(28th July 2015), There still exists an easy way to get page(or user's) id.
Browse to facebook page(or user) url. The syntax is https://www.facebook.com/[username or pagename]
Right click to view source and then search for string "pageID": in case of page. The numeric id next to searched string will be id.
In case of user, search for "uid":.
Been working with it today. So, for people who want to know how this works. Use this:
https://graph.facebook.com/<the_fb-address>?access_token=$accessToken
And remember: this is only for pages. Not user pages/friends' timelines etc.
Those will have to approve your Facebook App first before you can read their profiles.