Forum Discussion

rc225225's avatar
rc225225
New Member
10 years ago

Getting Facebook likes, comments and shares count

Hi all, 

 

I work in media and was wondering how I would be able to import Facebook data and be able to get the likes, comments and shares count for individual page posts. 

 

Have also tried this in power query in Excel 2016 but there seems to be a bit of a learning curve and I can't figure it out. Any help would be appreciated. 

 

Thanks :)

13 Replies

  • Thanks vasim07 that's what I suspected it was - good to have someone else with more expertise confirm this. However, I guess the main problem is the aggregation part - seems to rely heavily on the FB graph which is very very slow - guess there isn't a faster way to do this? 

     

    itchyeyeballs your problem is because the page you are trying to call from has too many posts - and I would guess that Facebook has a limitation as to how much data you can call in a single query. 

     

    Here's what I've done as a workaround - first of all when you pick what kind of data you'd like to get from Facebook, pick 'Statuses' instead of 'Posts'. Usually that does the trick and you'll be able to get some data first. Then once the window pops up you click "Edit". 

     

    Clicking edit will bring up the query. You then select "Advanced Editor" in which a pop up will appear with some code. Change to the following format:

     

    This is the original format:

     

    let
    Source = Facebook.Graph("https://graph.facebook.com/v2.2/PAGENAMEHERE/statuses")
    in
    Source

    --------

    Now the changes you have to make:

    1. Change 'statuses' at the end to 'posts' - because you want posts.

    2. You will need to set a limit as to how much data you are pulling from Facebook, so add the following after statuses: ?limit=100

    The number 100 is quite arbitrary but basically adjust it until you are able to pull data. 

     

    Looks like this:

    let
    Source = Facebook.Graph("https://graph.facebook.com/v2.2/PAGENAMEHERE/statuses?limit=100")
    in
    Source

     

    If you wish, you can even set some date parameters so the system will only pull in posts with the limit and between the dates you set:

    let
    Source = Facebook.Graph("https://graph.facebook.com/v2.2/PAGENAMEHERE/statuses?limit=100&since=2012-10-20&until=2012-12-31")
    in
    Source

     

     

    This should solve your problem with the errors.

     

    Meanwhile I'm still waiting for the FB graph to finish aggregating..sigh..there's got to be a better and faster way..

     

     

     

     

    • itchyeyeballs's avatar
      itchyeyeballs
      Icon for Impactful Individual rankImpactful Individual

      I got it to run in the end although its a bit flakey and falls over alot, refreshing the query seems to do the trick but thanks for the suggested workaround.

       

      The number of posts in the page I'm looking at was only about 800 which doesn't seem a lot, asside from the unexpected error I also sometimes get an error asking me to reduce amount of data requested, again a refresh resolves.

       

      The whole process It is very slow but I guess thats how facebook want it. Things seem to have improved a bit now its no longer lunch time, I guess FB throttle the API at busy times.

      • rc225225's avatar
        rc225225
        New Member

        Yeah - still trying to justify the value of doing this. At the very least this query is able to populate all the posts easily so if I were to do it by hand that already saves a bit of the work. 

         

        It is automation, but a very slow one at that. I was hoping for a faster way. Oh well - maybe we'll see better solutions down the road.

  • If not too many you can use a service like SharedCount and their API to get FB counts. I use an input file with many URLs and call their free API in Excel and load the counts.
  • Thanks for the help both - but it still doesn't solve the problem. 

     

    SharedCount is for external webpages - not for posts within the Facebook platform. 

     

    Again I'm looking for just a number count of the Likes, comments and shares so I can pull up some quick competitor analysis without having to do everything by hand. 

     

    Anyone else who knows how to do this please let me know, thanks :)

    • djnww's avatar
      djnww
      Icon for Impactful Individual rankImpactful Individual

      Hi rc225225,

       

      I was actually analysing facebook data from our company site when I read your post :)

       

      1. Within PowerBI Desktop, click on Get Data

      2. Scroll down and select 'Facebook'

      3. A message will pop up warning you that you will access a 3rd party site. Just click on 'continue'

      4. For the username, enter the name of the Facebook Page. For instance, Microsoft's Facebook page is 'www.facebook.com/Microsoft'. The name in this instance is 'Microsoft'

      5. Under connection, select 'Posts'.

      6. You will be asked to enter your credentials, which is your actual Facebook login details.

       

      I was analysing comments and posts. I'm not sure if Likes are available.

       

      Cheers,

      Daniel

       

       

      • rc225225's avatar
        rc225225
        New Member

        Thanks for your help - what I was looking for is not necessarily the posts, but just the data. 

         

        eg. Post 1 may have 100 likes, 25 shares and 56 comments. 

         

        I would then take the total of these and divide it by a certain percentage of the fanbase to get an overall feel for how competitor content performs. 

    • itchyeyeballs's avatar
      itchyeyeballs
      Icon for Impactful Individual rankImpactful Individual

      vasim07 - good stuff solves the issue I was having.

       

      New problem for me is that trying to import data for entities with larger amounts of data causes an unexpected error, for example MicrosoftBI works but MicrosoftUK doesn't