This tutorial offers you some options to download your (actually not only your) social network data. Basically here I give you 3 ways to deal with it:
The way you get your data is not that important, however you should know that options 1 and 2 import incomplete set of additional features of the network elements.
NodeXL is a free, open-source template for Microsoft Excel 2007, 2010 and 2013 that makes it easy to explore network graphs. In fact that's quite nice addon to make fast network analysis routines (made in подвал on коленка). Moreover, it has some build-in importers of social-web data (Flickr, Twitter, Youtube) and you are able to download additional importers.
Simply download installation file and follow the instructions. You may face an error, that states:
"The value of the property 'type' cannot be parsed. Could not load file or assembly 'Microsoft.Office.BusinessApplications.Fba,Version=14.0.0.0,Culture=neutral, PublicKeyToken=... or one of it's dependencies. The system cannot find the file specified. (C:\Program Files\Common Files\Microsoft Shared\VSTO\10.0\VSTOInstaller.exeConfig line 10)."
In this case you have to go to *C:\Program Files\Common Files\Microsoft Shared\VSTO\10.0* and rename VSTOInstaller.exe.config to VSTOInstaller.exe.config.old
You can find VK and Odnoklassniki importers here. Simply download archive and save files in arbitrary folder. Then go to NodeXL -> Import -> Import Options. There indicate the folder and restart Application.
Finally, go to Import -> From Vkontakte network importer. After you login with your account will get a notification to provide certain permissions to a vk.com app. Mark features you would like to import and push "Download" button.
Recently facebook have updated its private policy, so you cannot acquire personal impormation of your friend. Still there are some creepholes. As for NodeXL - you can download this importer and download network of co-likes\co-comments in Facebook fan-page or group-page.
Be aware that NodeXL importers are quike buggy and issues raises with number of additional features you want to store.
This section generally associates with Facebook. As you remember on your first seminar we have used Netvizz app to download your network. Unfortunately with the Facebook private policy update Netvizz has lost his ability to get your network data.
If you will be fast enough you can use GetNet which is still capable of downloading your friendship network. Probably it will also shut down after the 1st of April.
Workflow here is simple: link the applications with your Facebook account, choose additional features and download resulted .gml file.
An application-programming interface (API) is a set of programming instructions and standards for accessing a Web-based software application or Web tool. A software companies or web-services release their API to the public so that other software developers can design products that are powered to interact and with their services.
So our first step here is to create a Standalone Application here. In "Settings" menu you need to find and remeber your Application ID.
Actually from this moment you already can get your frindship network. But some of the API Methods require addtional permissions to handle page data. So you need to get an *access token* -- special line of sumbols that identifies you and your app creditals and set of previlliges. On this page you can find the template to authorisation request to get this token.
The parameter of particular interest here is scope parameter, which identifies the priviliges of your app. An access to friends should be enough for your, so your authorisation request should be somewhat like this:
Replace APP_ID with your app id and copy this link to your browser. You will see a pop-up window with confimation of the app priviliges. Afterall adress line of your browser will contain access token -- copy it and show to anybody! Note that your token has a lifetime. When it expires you should repeat your authorisation request.
Let's try to run some API methods directly:
import urllib2, json, sys
# Your token - sequence of symbols that goes after access_token=
token = ''
# Suppose you want to get a friendlist of a particular user.
# You also want hometown, sex and education to be contained in this list.
# Finnaly, I suggest to put lang=en to aviod cyrillic issues
uid = ''
url = u'https://api.vk.com/method/friends.get?fields=sex,city,education&uid=%s&lang=en&access_token=%s' %(uid ,token)
res = urllib2.urlopen(url).read()
data = json.loads( res )
Variable data contains information in json format
uid = ''
url = u'https://api.vk.com/method/friends.get?fields=uids&uid=%s&lang=en&access_token=%s' %(uid ,token)
res = urllib2.urlopen(url).read()
data = json.loads( res )
# Access to the first user in friendlist
data['response']
# Access to his\her last name
data['response'][0]['last_name']
In fact there is a Python module that makes your life a bit easier. You can install in by typing pip install vk in your terminal window.
import vk
# Use app id, user email/phone and password for access to API
vkapi = vk.API('my_app_id', 'user_login', 'user_password')
vk.access_token = token
profiles = vkapi.users.get(user_id=1)
profiles[0]['last_name']
# Your uid
me = ''
# Using results of get.friends request
uids = []
for u in data['response']:
uids.append(str(u['uid']))
uids = ','.join(uids)
# Mutual Friends Request
url = u'https://api.vk.com/method/friends.getMutual?target_uids=%s&source_uid=%s&lang=en&access_token=%s' %(uids, me ,token)
# Our Result
res = urllib2.urlopen(url).read()
data = json.loads( res )
data['response'][0]
In fact VK API limits number of requests per second for apps with <= 10000 users. Thankfully, getMutual method has target_uids parameter for multiple target uids. In case you want to reduce number of requests I suggest you to implement your own Stored Function (find it in your app-management menu) and use execute method.