API of the Day: facebook fql direct from Excel and Google APPs

Someone asked in our forum yesterday about Facebook Query Language – FQL. Could we get data straight into Excel from facebook? I dont use facebook, so I haven’t paid much attention to it. I had a look anyway. It seems there is a lot of useful data you can get out without needing a developer key so I implemented an entry in the Rest Library (both Excel and Google Apps Script)

Here’ the result, of a query on google locations (google headquarters has 12 million fans, and none of them have been there?)

The syntax is Sql like, and it can be passed as a simple Rest query, and gets a json response.

Here’s a simple test query that generates the above.

Public Sub testFql()
    Dim fqlQuery As String
  
    fqlQuery = "SELECT name, location.street, location.city, location.state, fan_count, talking_about_count, " & _
        "were_here_count FROM page WHERE CONTAINS('" & _
        InputBox("name contains ?") & "') and location.city != ''"
       
    generalQuery("fql", "fql", fqlQuery).tearDown
End Sub

and the same thing in GAS.

function testFql() {
    var fqlQuery =
      "SELECT name, location.street, location.city, location.state, fan_count, talking_about_count, " +
        "were_here_count FROM page WHERE CONTAINS('" +
        mcpher.InputBox("name contains ?") + "') and location.city != ''";
       
    mcpher.generalQuery("fql", "fql", fqlQuery);   
}

Plenty of potential if you are interested in getting data out of facebook.

You can see these in  ‘restlibraryexamples’ module in cdataset.xlsm, which you can download from the Excel Liberation site, or in the Google Docs version here.

About brucemcp 225 Articles
I am a Google Developer Expert and decided to investigate Google Apps Script in my spare time. The more I investigated the more content I created so this site is extremely rich. Now, in 2019, a lot of things have disappeared or don’t work anymore due to Google having retired some stuff. I am however leaving things as is and where I came across some deprecated stuff, I have indicated it. I decided to write a book about it and to also create videos to teach developers who want to learn Google Apps Script. If you find the material contained in this site useful, you can support me by buying my books and or videos.