Recently I had to analyze interactions on a Facebook page. I need to fetch all the contents from the stream and analyze user actions. Retrive interactions count foreach post can be hard because Facebook APIs are like hell: they change very fast, return a lot of errors, have understandable limits and give you many headache.

Anyway after a lot of tries I found a way to fetch quantitative informations about posts and photos on the stream. First of all you need the contents.

Get the contents

Graph endpoint is: You can fetch page data (I use the BBCNews page as example) at:

To get a valid access token you have different ways and Facebook let you choose many different kind of access tokens, each one with a different rate limit.

Returned data is a JSON array of elements. Each elements has a lot of properties which describe items on the timeline. The returned element included into the stream has just a subset of these properties (last comments, last likes, some counters). Here you can find text content, pictures and links. To get more data you need three more properties: id, type and object_id.

Status updates are identified by type “status”Photos are identified by type “photo” and Video by type “video”. The id field is used as identifier for the entry on the stream. The object_id instead is used to identify object inside the Facebook graph.

Actions: comments, likes and shares

Comments are returned paginated and sometimes APIs doesn’t return the entire list. To get the total count you need to specify the parameter summary=true.

At the end of response you can find additional informations about comments feed. total_count displays the count.

"summary": {
"order": "ranked",
"total_count": 100

Likes are similar to comments. They have similar limitations and have a similar endpoint to retrive data with the same parameter summary=true.

This time summary shows only total count:

"summary": {
"total_count": 949

Shares count can be found as part of the object detail.

After created and updated date you find shares property:

"shares": {
"count": 238

Convert the object_id

Depending on you data feed, sometimes id is not available and you have to handle the object_id. To be able to use previous methods you need to query the Facebook database using FQL looking for the story_id.

SELECT page_story_id
FROM photo
WHERE object_id = '10151700273362217'

The result is the page_story_id (the id of the post on the feed) of the object.

"data": [
"page_story_id": "228735667216_10151700273382217"

Now you can use this to retrieve counters and data.

Last week I started to play with my RaspberryPi (thanks @dani_viga). It seems simple and funny. I’d like to run an Hadoop cluster like LinkedIn or others geeks but first of all I need to setup the system.

My RaspberryPi kit includes the board, an USB-microUSB cable (as power supply), an SD card (16 GB) and an ethernet cable.


pidora_logoAs Linux distribution I choose Pidora because I like CentOS and this a Fedora/RedHat-like distribution. Base image can be downloaded from official page. Then you have to burn the image on the SD card. It seems that RaspberryPi can boot only from SD card. I can’t find any guide to boot it from USB key without SD card. Anyway is possible to use it as main drive. To burn it on SD on Mac o Linux you can use dd

dd if=/path/to/image/pidora-18-r1c/pidora-18-r1c.img of=/dev/disk3 bs=1m

First parameter is the path of the downloaded image, the second one is the endpoint of the SD drive (you can find it using diskutil list).

After this I simply plugged USB to my Mac and ethernet to a connection. After a dozen of seconds lights start blinking!


System is already configured and on port 22 runs SSHd. If you try to connect to the IP using root as username and raspberrypi as password the RPi answers!


Next week I’ll try to install a LEMP stack on it. FUN! 😀