Welcome Guest, you are in: Login

QVSource - The QlikView API Connector (Docs)

»

RSS RSS

Navigation

For Everyone
For QlikView Users
For Advanced Users
For .NET Developers
If you like QVSource please consider showing your interest and support.





Search the wiki
»

Wiki Links


PoweredBy

Klout Connector for QlikView

RSS
Modified on 2012/05/08 17:19 by chrisb Categorized as connector, demo apps, social

Klout Powered

NOTE: We are now working on v2 of this connector.

Usage

First of all, please ensure you adhere to the Klout API terms of use when utilising this connector.

Once you have done this you can enter one or more comma separated Twitter names into the input box:

Image

And view various results for those users:

Image

Development Mode

Currently all users of the Klout connector are 'sharing' the same API quota limits. Therefore we strongly urge all users to use the connector in 'Development Mode' whilst developing and debugging applications.

Image

This will cause random results to be returned for both the User and KloutScore tables.

This will benefit all QVSource users by improving response times and reducing the likelihood that they will receive an API quota limit error when real data is needed. It also has the added benefit of greatly improving the load performance!

This option simply toggles the 'ScriptMode=' parameter in the load script to either:


KloutConnector_User:
LOAD
	twitter_id as User_twitter_id,
	... etc ...
FROM
[http://localhost:5555/QVSource/KloutConnector/?table=User&TwitterId=$(twitterHandle)&format=html&ScriptMode=Development]
(html, utf8, embedded labels, table is @1);

Or


KloutConnector_User:
LOAD
	twitter_id as User_twitter_id,
	... etc ...
FROM
[http://localhost:5555/QVSource/KloutConnector/?table=User&TwitterId=$(twitterHandle)&format=html&ScriptMode=Production]
(html, utf8, embedded labels, table is @1);

And is therefore easily handled using a script level variable, something like:


let scriptMode = 'Production';

if(vDevMode=1) then
	scriptMode = 'Development';
endif

KloutConnector_User:
LOAD
	twitter_id as User_twitter_id,
	... etc ...
FROM
[http://localhost:5555/QVSource/KloutConnector/?table=User&TwitterId=$(twitterHandle)&format=html&ScriptMode=$(scriptMode)]
(html, utf8, embedded labels, table is @1);

This is illustrated in the demo application below.

Simple Usage

This connector can be applied on a row by row basis to a table already containing the Twitter account names you wish to establish the Klout score for.

So for example in the demo app below we user the Twitter Connector to return a list of tweets matching a certain search phrase. We then loop through this results table, named 'TwitterConnector_Search', as shown below and run the Klout connector against each result.


//
// We strongly encourage users to set this value to 'Development' while developing and testing 
// apps. This will help everyone by reducing the number of API calls made to Klout and leaving 
// more calls for real workd usage. It also means the scripts will load faster!
//
let scriptMode = 'Development'; // This can be 'Development' or 'Production'

// A nice way to switch this is via a variable in the application.
if(vDevMode=0) then
	scriptMode = 'Production';
endif

LET noRows = NoOfRows('TwitterConnector_Search'); // get the total number of rows in the table
    
for i=1 to $(noRows) // loop through every row
     
	let twitterHandle = FieldValue('Search_from_user', $(i));
	
	KloutConnector_User:
	LOAD
		'$(twitterHandle)' as Search_from_user,
		status as User_status,
		twitter_id as User_twitter_id,
		twitter_screen_name as User_twitter_screen_name,
		kscore as User_kscore,
		slope as User_slope,
		description as User_description,
		kclass_id as User_kclass_id,
		kclass as User_kclass,
		kclass_description as User_kclass_description,
		kscore_description as User_kscore_description,
		network_score as User_network_score,
		amplification_score as User_amplification_score,
		true_reach as User_true_reach,
		delta_1day as User_delta_1day,
		delta_5day as User_delta_5day
	FROM
	[http://localhost:5555/QVSource/KloutConnector/?table=User&TwitterId=$(twitterHandle)&format=html&ScriptMode=$(scriptMode)]
	(html, utf8, embedded labels, table is @1);
 
next

Advanced Usage (Recommended)

You can and should concatenate together Twitter screen names in a comma separated list.

The connector will take care of splitting these out into individial requests. This results in fewer requests to the Klout API and improved response times.

The sample QlikView script below illustrates how this can be achieved.


let users = fieldvaluecount('Search_from_user');
let concatenated = fieldvalue('Search_from_user',1);
let currentCount = 1;
 
for i=2 to $(users)
 
    let sep = ',';
      
    if(concatenated = '') then
        let sep = '';
    endif
      
    let concatenated = concatenated & sep & fieldvalue('Search_from_user',$(i));
    let currentCount = currentCount + 1;
   
    if(currentCount >= 99 or i=$(users)) then
         
		KloutConnector_User:
		LOAD
			//'$(twitterHandle)' as Search_from_user,
			status as User_status,
			twitter_id as User_twitter_id,
			twitter_screen_name as User_twitter_screen_name,
			twitter_screen_name as Search_from_user,
			kscore as User_kscore,
			slope as User_slope,
			description as User_description,
			kclass_id as User_kclass_id,
			kclass as User_kclass,
			kclass_description as User_kclass_description,
			kscore_description as User_kscore_description,
			network_score as User_network_score,
			amplification_score as User_amplification_score,
			true_reach as User_true_reach,
			delta_1day as User_delta_1day,
			delta_5day as User_delta_5day
		FROM
		[http://localhost:5555/QVSource/KloutConnector/?table=User&TwitterId=$(concatenated)&format=html&ScriptMode=$(scriptMode)]
		(html, utf8, embedded labels, table is @1);    
         
        let concatenated = '';
        let currentCount = 0;
                 
    endif
     
next

Changing the Default Cache Time

By default the connector will cache the Klout score for 1 day. If you would like to change this just add the following parameter in the http request section of the load script.

http://localhost:5555/QVSource/IndustrialCodeBox_KloutConnector/?table=KloutScore&TwitterId=qvsource&cacheAgeInHours=48

The cacheAge can be between 0 and 144 (6 days).

Demo App

You can download a demo app which uses this connector in conjunction with the Twitter Connector here:
Klout Demo App V1.1

Image

Adhering to Klout's Terms

To use the Klout API, there are really only three things that you must do:

  1. Give Klout some logo love. Give us, and our data, credit by using our logo and linking to us as possible. Check out our attribution requirements at http://developer.klout.com/API_Terms_of_Use and get the style guide and visual elements at http://developer.klout.com/docs/read/Style_Guide.
  2. Mind the Terms of Use at http://developer.klout.com/API_Terms_of_Use. Especially, the 7-day caching policy and no bulk exporting of our data.
  3. Note that our developer call limits are 10,000 calls per day and 10 calls per second. Contact partners@klout.com if those limits are insufficient.

Please refer to their documentation at http://developer.klout.com/iodocs for more about the information that Klout makes available.

PLEASE NOTE: In reference to point 3 above, Klout have been kind enough to bump our current allowance up to over double this but this is shared across all users of QVSource so please use respectfully!

Change Log

1.0.8 - 20/04/2012
  • Added twitter id of user being queried in InfluencedBy and InfluencerOf tables.
  • Added kscores of influncers/influencees returned in InfluencedBy and InfluencerOf tables.

1.0.7 - 31/01/2012
  • User table (as well as KloutScore) table now supports the ScriptMode=Development parameter (to create random values for testing).

1.0.6 - 13/01/2012
  • Minor change to contents logged when API call tracking is turned on.
  • Default cache time now increased to the maximum of 6 days to minimised calls to the Klout API. This will benefit all users, please only use a shorted cache time if absolutely necessary (Klout scores generally don't change that rapidly so in more cases there should be no need).

1.0.5 - 14/12/2011
  • Reports back more useful error message if it can find X-Mashery-Error-Code http header in error response.
  • Handles requests with multiple Twitter screen names in the same way as single requests (i.e. returns one row per twitter name with associated error message instead of no rows as previously.
  • Fixed issue where certain tables (e.g. InfluencedBy) had columns missing if Twitter screen name was not found.
  • Added a 'Development Mode' option to return random (normally distributed) score for KloutScore table. Expect to expand this to User table in the future.
  • Scrore of 10 is now returned for certain API error responses (where user is not found) as recommended by Klout.

1.0.4.1 - 25/11/2011
  • Now throws an exception if no TwitterId parameter is specified in url request.

1.0.4 - 07/11/2011
  • IndustrialCodeBox_KloutConnector now referred to as KloutConnector in load scripts.
  • parameter random=true can now be passed in load script for testing and development pusposes

1.0.3 - 07/11/2011
  • Certain user names started returning a strange error ({"status":200,"headers":[],"body":{"error":"No users"}}) even when
    the user being requested was a valid Twitter user and xml response was being requested. Code has been added to better handle
    this.

1.0.2 - 12/10/2011
  • Added User, Topics, InfluencedBy and InfluencerOf tables.
  • Can now pass in an additional parameter to the http request - APIKey=???? - If you have a Klout API key.
  • You can now pass any number of comma separated screen names, the connector will take care of calling them in batches of 5. The QlikView script no longer needs to split them up.

1.0.1 - 17/08/2011
  • Default cache period is now 1 day. This can now be edited by supplying a cacheAgeInHours= parameter between 0 and 6x24.

1.0.0 - 10/08/2011
  • Now accepts a comma separated list of user names for improved performance.
© Copyright 2011 - 2012 Industrial CodeBox Ltd