PowerUp
Talend Facebook Application component

tFBAppData



Background :

Facebook is now used for personal and business purposes, plenty of applications have been created for this social network.
Now Facebook allows even "external" applications (i.e. websites) to be recognized as "Facebook Application", it's enough to register (the registration is free and simple) a Application entry.
Then your application will have some kind of interaction with Facebook (that depends on the type of application you developed) and this will generate some "stats", that Facebook calls "Insights".

Facebook's official page for Insights can be found here : http://developers.facebook.com/docs/insights/
Additional information can be found here : http://www.facebook.com/help/search/?q=insights



Fore real applications (not the test one you can see in the picture :) ) this data can be estremely valuable, as you can discover how many users "intalled", interacted with, liked it etc.
This data is also available via a data flow in JSON format using the FB graph protocol, so it can be retrieved and stored in a proper database.

The solution

Using a webservice interface (the same we used here) we can connect to the facebook graph api, issue a query and decode the json information returned, which becomes a data flow in Talend.
Technically a java library (included in the component) takes care of the protocol, exposing high level functions to the component.

Current version

Version : 0.1
Release Date : September 1 2011
Status : Alpha


Usage

This is an input component, meaning it will be used as a "source" of data, at the beginning of a subjob.
To use it, you need to have access to a Facebook Application data (you need the Application ID, and the Application Secret Code), which are required parameters for the component.

If you have a FB application registered, you should know where to find them, if you don't check this link, tin the image below they have been partially obfuscated.


The schema of the generated flow is predefined and fixed, so it does nto require your intervention.
We use the same schema for both the two ways the component can operate :
- With Values
- Without Values

To switch from one mode to another, you have to set the value of the "Fetch values?" checkbox.
The last two fields will have null values if the flag is unchecked.


The Graph Insights APIs return json data in the following format :



{
    "data": [
  {
   "id": "21xxxxxxxxxxxx90/insights/application_bookmark_adds/day",
   "name": "application_bookmark_adds",
   "period": "day",
   "values": [
    {
     "value": 0,
     "end_time": "2011-08-28T07:00:00+0000"
    },
    {
     "value": 0,
      ....


As you can see there is a "values" sub-table for each record, normally we would output two tables with a master/detail relationship, however this would have increased the complexity of the component, so we decided to merge the two in one single table-
Still you may need to simply get the list of the available Insights Items, without the values, for this reason the component has a flag to enable or disable the subtable, this flag is identified in the parameters with the label "Fetch values?".
You have to check it if you want to retrieve the "value" subtable.

Values can also (optioanlly) be restricted within a time period (it can be an open period, meaning you can set the start and not the end and vice-versa) however a maximum number of days is allowed.
If you do not specify any date filter, Facebook will return the last 3 days only (for day period based indicators)

I am not sure how this affects indicators that are not based on daily periods.

The graph protocol expects Unix timestamps to filter the dates, however the component performs the conversion for you from an easier format, being "YYYYMMDD".
Finally, i is also possible to restrict the query to a specific indicator, you need to get the "id" (note, the id will start with you application id code, you can either leave it like this in the filer or you can remove it, the java library will handle both cases accordingly, it will make no difference) and place it in the "Insights Item" parameter.
This parameter must contain a valid ID or be equal to "" to fetch all the indicators.


Example In the example job shown in the picture below, two instances of the compoenent have been used : the first one with the option"fetch values" set to "off", to get only the header values (that we will eventiually store in a table), and the second one to get the values and the related id, to eventually store them in a second table that can be related to the first one using the id.

The header table is loaded first as you may want to have foreign key constraints between the two tables, also the load strategy would probably be "delete/insert" using keys ID for the header and ID,ENTIME for the values.



The example job is also available in the download section at the bottom of the page.


If you have questions, suggestions or requests, feel fre to contact us using our feedback module.
Facebook Grpah Api is documented here : http://developers.facebook.com/docs/reference/api/

Note about the installation of the component in Talend : Normally the whole process is automated and should run smoothly regardless of the OS and version you are using, however in some cases the attached java libraries (jar files) are not copied automatically by the standard install procedure.Should this happen, you will probably received an error message when trying to execute a job that contains the component, saying that a given object cannot be resolved to a type.
To fix this eventual issue, open the compoenent folder, locate the jar files and copy them in the folder /lib/java.



Downloads



License

THIS SOFTWARE IS PROVIDED BY POWERUP ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL POWERUP BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.