Getting the number of installations of an application using FQL

We can use the Facebook insights table to query for the number of installations of our application up to a specified date. Here, we will show you how to do it.

Getting ready

You should have created index.php and config.php as mentioned in the beginning of this chapter. Also, you should have provided read_insights extended permission to the application.

How to do it...

The following steps will demonstrate how to get the number of installations of an application:

  1. Open index.php and append the following code to it:
    <?php
  2. Write a query to retrieve the number of installations of the application:
     $results = $facebook->api( array( 'method' => 'fql.query', 'query' =>"SELECT metric,value FROM insights ...

Get Facebook Application Development with Graph API Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.