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.

(function() {
var po = document.createElement(‘script’); po.type = ‘text/javascript’; po.async = true;
po.src = ‘https://apis.google.com/js/plusone.js’;
var s = document.getElementsByTagName(‘script’)[0]; s.parentNode.insertBefore(po, s);
})();

Author: brucemcp

Leave a Reply

Your email address will not be published. Required fields are marked *