Facebook Graph API: collecting group statistics - facebook

I am member of a facebook group, and the group is now growing to more than 2000 members, and somebody asked a question: where everybody was from. Cool question: nice to know.
That got me thinking: wouldn't there be a more convenient way to get this information? So I went looking for some API, found the Facebook Graph API, found the API explorer and dove right in.
So I create a token, and inside that token I generally declare what I am allowed to acces, but this token can only access ... the things I can access.
So, for instance it is possible for me to
list my groups
list members of one of those groups
So I assumed I would be able to get public info for those members, hoping I could find age/gender/location, and then I could create a map/dashboard of some kind, which would be cool.
But afaik that is not possible. If I request the details of a user, I get only the most basic info:
{
"id": "...",
"first_name": "...",
"last_name": "...",
"link": "https://www.facebook.com/app_scoped_user_id/.../",
"name": "...",
"updated_time": "2014-09-12T17:02:18+0000"
}
I attempted to get more fields, using the /#{user-id}?fields=gender,location but that does not show anything more. In a way logical, because my token does not allow me to access this particular user, only my own user (right?).
So my question is in general: how can I gather statistics of a facebook group?
Possible solutions I can think of:
request a token from all members, so I can collect their info? This seems completely impractical.
for each member I can visit their public facebook page, and scrape the public info
But as a total Facebook API noob I am guessing there should be better ways? Also I am actually not interested in the personal data, just the generic statistics of a group, but from the API documentation I did not find any entry for that.
Or should I create an APP and all members of a group have to "install that APP" and then you can install that APP in the group which would add an extra page??? (ok: obviously also a Facebook APP noob).
All help, tips or remarks are greatly appreciated.

The current Facebook API as you noticed will only give you extended info pertaining to yourself. To get extended information for other users, those use must sign into an app that you own and grant access.
You are probably looking for location which requires user_location permission https://developers.facebook.com/docs/facebook-login/permissions/v2.0#reference-user_location. Seeing that you will be using this for statistical purposes I don't believe you will permission request to Facebook will be reviewed.
With respect to your solutions
request a token from all members, so I can collect their info? This seems completely impractical. Agreed and you will not be approved for this permission anyway
for each member I can visit their public facebook page, and scrape the public info. You are violating the TOS and Developer policy here
So there is no way within the API, within policy to determine group statistics.
What follows is not recommended and just shows it is practical but not a good way to go about it
Facebook Native apps (Facebook for IOS/Android, Facebook Messenger, Facebook Pages) have special access to data and in addition are still running v1.0. Theoretically, one can use the access_token belonging to one of these apps then request the data /{group-id}/members?fields=id,gender,location is one way to do it.
Also all v1.0 applications still return the gender field for any user.

Related

Instagram Graph API getting users geolocation without login and access token

I know that you want to suggest me private api or any scraper. I used them but they don`t return accounts geolocation. In my application I want to get instagram accounts geolocation, likes, comments, followers and follows in order to get engagement of account.
If you say it is not possible look TrendHero website it returns all information about users, followers rank, country information and other handy information which you can find in your insights (in instagram account) without users permissions.
My first impression, without caring to dive deep into the company you linked, is they are simply using scrapers. That's typically how those big contact databases are done.
The Instagram APIs simply don't provide the access they used to. That's how it is. Simply asserting there must be a way doesn't mean there actually is.
#WizKid Instagram can't actually prevent scraping. They just make a little fuss about it.

Facebook graph access closed group feed/posts

I am trying to get a list of posts in a particular group on facebook that is closed, also I am not the admin, just a member in this group. When I am trying to access the group's posts via graph explorer (I checked all the permissions) I am getting an empty list returned.
What is facebook's reason for not allowing this access? If I am a member of this group I have access to this information anyway via browser/scraping...
Your thoughts and suggestions are appreciated.
What is facebook's reason for not allowing this access? If I am a member of this group I have access to this information anyway via browser
That would be only you being able to see the posts then, fine. Two parties involved - you, and the other group members; everyone aware of who will be able to read the posts, all good.
But with an app, a third party gets involved - the app developer. And they could theoretically do anything with that data, that the app reads from the API on your behalf. (Sure, the app developer might be you in this special case here - but that is not the normal use case.)
And in a closed group people might discuss topics that are a little more sensitive than the current weather; think f.e. health problems or something like that. For sure not the stuff you’d want exposed to any third parties.
And therefor, the decision whether an app should be able to read the group’s feed posts, has been placed in the hands of the group admin(s).
If you would like to access the data use api version 2.3, the only downside is that it will be deprecated.

Facebook - public posts not appearing in Graph?

I am currently trying to get the posts for a specific user from Facebook's Graph API. I have done this numerous times before using a php script I have developed; but the problem this time seems to be on Facebook's end, not mine.
I am trying to get the posts from (replacing TOKEN with an access token):
https://graph.facebook.com/100001558773450/feed?access_token=TOKEN
The graph won't show any posts by the owner of that page but will show everyone else's posts, and as far as I can see the posts are marked as public, and there are no privacy settings set on the account that would stop it from adding the posts to the graph.
Any ideas?
Thanks,
Nick
Check that you have requested the manage_pages permission to give you full access to the page (if you need access as the "page owner").
Using the access_token you've got, according to this documentation there are three different things that you can select feed, statuses and posts.
I'd give those three a go from https://graph.facebook.com and if what you get back is what you require.
https://graph.facebook.com/100001558773450/feed?access_token=...
https://graph.facebook.com/100001558773450/statuses?access_token=...
https://graph.facebook.com/100001558773450/posts?access_token=...
You need to check the "profile" privacy settings (what to share with apps). But most importantly, this is against Facebook ToS!
You can't use a user profile to represent your business, you need to use Facebook pages instead!
More can found here:
Why should I convert my profile (timeline) to a Page?
Since profiles
(timelines) are for meant individual people, they aren't suited to
meet your business needs. Pages offer more robust features for
organizations, businesses, brands, and public figures, which you can
learn more about here.
Further, maintaining a profile (timeline) for anything other than an
individual person is a violation of Facebook's Statement of Rights and
Responsibilities. If you don’t convert your profile (timeline) to a
Page, you risk permanently losing access to the profile (timeline) and
all of your content.

Default FB search

I read documentation about FB API, and FB graph, and still not sure how to do something.
I'm creating unique client for FB and G+, and when i log in with some user (with no friends for example) I need to make default search, and to try to add friend.
However, when i do any kind of FQL search, i receive almost empty results, with no publicly shown data that i receive when i use FB mobile application, or just when i try to find someone on FB. Is there any chance to do that, and what kind of token i need to have.
It would be silly to create FB application, and wait for users to approve permissions for me, so later I can search for them, and add them as friends or so...
Is there any example, or any suggestion how to do that, i searched, and searched, and still nothing :(
Thanks in advance
Edit:
Well, i'm trying to use Graph API (i don't know if i can use any other).
I want to create application that i will be able to use as same application for facebook and google social network. So i need to login, and than to search for people (like in regular FB), and to add them as friends etc.
So, i'm trying to search for people with given string (i know that), to find info about user (i need permission and token, even if those info is public, or in other words, user needs to authorize my application, so i can later allow people who use my app to search for user, and have public info)
So, my question is, if there is any way to search user and his public info, available on FB application on mobile devices ?
Go to http://developers.facebook.com/docs/reference/api/ and CTRL+F for Searching section. You can use that to search for Facebook users.
But, as you said, you won't have the current user access_token, so you won't be able to perform the search. And if you try to use /search with an app access_token the response message is:
{
"error": {
"type": "OAuthException",
"message": "A user access token is required to request this resource."
}
}
So you need to create a Facebook App and get user permissions to perform the searches you want.

How to crawl Facebook based on friendship information?

I'm a graduate student whose research is complex network. I am working on a project that involves analyzing connections between Facebook users. Is it possible to write a crawler for Facebook based on friendship information?
I looked around but couldn't find any things useful so far. It seems Facebook isn't fond of such activity. Can I rely on the Facebook API?
Update (Jan-08-2010): Thank you very much for the responses. I guess I probably need to contact Facebook directly then. Cheers
Update (Feb-16-2011): A new book, "Mining the social web", just came out. In it, there is a chapter devoted entirely for mining Facebook using Python. Cheers.
You can't rely on the Facebook API unfortunately. To get friend information, you need to use something like friends.get(). However, any Facebook API method that returns user information like this requires that you have an active session key from that user, and generally the way you get an active session key is to have the user come to your Facebook application or page.
In summary, the information you are talking about is essentially private. You can't pick a person from Facebook, get their friends, and get those friend's friends, and so on. To me this is a good thing for privacy, but of course it prevents arbitrary analysis.
I'd throw out the idea of writing a quick and dirty application with some user appeal that you could use for research. If a group like S**t My Dad Says (funny, not really safe for work) can get 120,000 users in a couple of months, you could probably plead your case with a small research application and get a reasonable amount of users.
The problem is that facebook friendship information is typically private and only accessible to friends. It should be a lot easier to build this network on Twitter, if this is an option for you.
As others have stated, this is typically private information. If, however, Facebook per se isn't a requirement, you could use Google's Social API. A snippet from the Google Social Graph API page: "With the Social Graph API, developers can now utilize public connections their users have already created in other web services. It makes information about public connections between people easily available and useful."
Here's an article on using it in Ruby:
http://articles.sitepoint.com/article/google-social-graph-api-ruby-rails#
This lifecode post provide a basic python script to scrape your facebook friends contact info.
The output of this script, is the profile ID, profile pame, profile URL, e-mail address and mobile/phone number (if provided by friend).
WARNING: This is against Facebook TOS. Use at your own risk.
Info provided for educational and research purposes
http://ruel.me/blog/2010/11/26/scrape-your-facebook-friends-contact-info-with-python/
You can use http://www.facebook.com/directory/ to get the public listed people.