MATLAB Answers


How to read Facebook information in MATLAB?

Asked by Adriano
on 18 Aug 2011
Latest activity Edited by ali fadaie on 3 Apr 2017

I want to read data from a group in Facebook to make a statistical analysis (number of posts by each member, number of "likes", etc.).

How can I access Facebook to extract this information?

I would appreciate any information that could point me in the right direction.

  1 Comment

Looks like you may be working toward the one useful use for Facebook.
Congrats +1

Log in to comment.

2 Answers

Answer by Sreeram Mohan on 18 Aug 2011
 Accepted Answer

I just tried a thing quickly !

[Object Status] = urlread('')

The Object should contain the relevant data which could be parsed to get the required info and the status returns if the attempt succeded !

Getting a good JSON object parser would make extracting information more easier though !

I tried using one of the file exchange submission here and it works smoothly with no issues !

Hope this helps better !


  1 Comment

hi teacher.u can help how fetch data in facebook matlab??

Log in to comment.

Answer by Sreeram Mohan on 18 Aug 2011

Here is an API published by facebook

You should combine the calls with the matlab functions like urllread ..etc to get the data that you require !

Let me know if you need help !



Well, let me explain, I´m working with a proyect where I have to take sharing images of last 6 months from any facebook counter. The images will be download. After, these sharing images are going to analyse in Matlab with process image algorithm for example OCR. I think that I need to create an API if I want to get sharing images from any facebook counter I hope you can understand me. Thank you

I never worked with FB, so you should open a new thread and see if someone did it. The API is not something that you write, but something that you interact with. It is a way for you to access data programmatically and not through the usual "user friendly web page interface". It is not always available and sometimes you have just the web pages to work with. When available, it is documented usually in a developer section and the documentation tells you how to send a query to the server, and how to read what is returned.

When not available, you are left to parsing web pages. This is not always possible, e.g. when there is Flash or some client-side code like JS. When the information lies in the HTML source of web pages though, you can generally extract it using an XML parser (for the simplest and best structured pages), or regular expressions if it is not XML compliant (most cases are not) and you need to extract data using pattern matching. Images can be saved as well in this case, because you can extract their URL and it is easy to download them.

I know that FB has a developer portal and APIs. Your next moves should be..

  • Look at the FEX if someone implemented something relevant to your work already, or anything related to FB.
  • If not, check if you get anything through google (e.g. "How to extract facebook information using MATLAB").
  • If nothing is already available, see if there is an API by FB which can provide the data that you need.
  • Then open a new thread here that explains what you are trying to achieve, reference what you found on the FEX or elsewhere already if there is anything (and explain in what it doesn't solve your problem). Also describe what you found in the dev. corner at FB, if there is an API that could be used, etc.

If you get no information, no answer, find no relevant API, but you are able to describe precisely what you need to extract from specific web pages (provide examples), we can talk about a solution that extracts data from the HTML code of these web pages (if available). This is in fact what I did in my small example.

PS: if you open a new thread, please post a link here as a comment so I see it.

Log in to comment.

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today