Twitter Cartridge - Configuration Guidelines and Implementation Notes
Introduction
Virtuoso's Cartridges VAD includes two Sponger cartridges for Twitter, listed as "Twitter" and "Twitter v2" in Conductor's Sponger Configuration UI.
The most recent of these, "Twitter v2" is written for the Twitter REST API and OAuth.
The other earlier cartridge was written for a previous version of the Twitter API and uses basic HTTP authentication.
It is disabled by default when the new cartridge is present.
These notes, intended for a 'Sponger Administrator', provide configuration guidelines and brief implementation details for the new cartridge.
Registering the Sponger as a Twitter Application
Before you can obtain access tokens for the cartridge, you first need to register the Sponger as a Twitter application.
- Register the Sponger using the Twitter Developers Application.
- Click "Create an app".
- In the presented form:
- Specify application name, for example: 'Sponger_{your_host_name}' ;
- Specify your website ;
- Specify callback URL: it must point to the Virtuoso /twitter_oauth Virtual Path defined when the Cartridges VAD package is installed, e.g.
http://{your-virtuoso-host:port}/twitter_oauth ;
- Hatch the "Yes, I agree" check-box;
- Enter the "CAPTCHA" words:
- Finally click "Create your Twitter application" button.
- The application will be created and a Consumer key and secret will be generated:
- Now go to your local Conductor at http://your-virtuoso-host:port/conductor
- Go to Linked Data -> Sponger -> Extractor Cartridges:
- Find "Twitter v2" and click on its link in order to edit its properties:
- Should be presented the cartridge's configuration details at the bottom of the page list:
- The 'Cartridge name' as DB.DBA.RDF_LOAD_TWITTER_V2;
- Configuration options:
- consumer_key=xxx
- consumer_secret=xxx
- friends_n_followers_pg_limit=0
- friends_n_followers_item_limit=20
- favorites_pg_limit=1
- user_timeline_pg_limit=1
- Enter the API key and Secret Key noted in the cartridge's "Options" field as values for options consumer key and consumer_secret:
- Click 'Update" to save the "Options" settings.
Granting an Access Token
The Twitter user whose profile is to be fetched should first grant an OAuth access token.
This can be done through the Twitter button displayed by http://{your-virtuoso-host:port}/sponger:
- Go to http://{your-virtuoso-host:port}/sponger :
- Click the Twitter button:
- Click the "Authorize app" button.
- As result a notification for successful OAuth access token generation should be displayed:
Although it is not mandatory that each user grants an access token, at least one must have been granted so that requests to the Twitter REST API can be signed and Twitter can authenticate the caller.
Thus one user's access token can be used to fetch another Network Resource user's profile.
View the Retrieved Data
The cartridge is configured to trigger on the URI pattern http://twitter.com/.*, i.e.
the expected starting point for sponging a Twitter user's profile is a URL of the form http://twitter.com/{screen_name}.
For example:
- Access http://uriburner.com/about/html/http://twitter.com/kidehen :
- Click the primary topic value link "Kingsley Uyi Idehen":
Alternative Follow-Your-Nose friendly view of a Twitter Data Object that represents a Person
We can take a look at the /fct variant of the primaryTopic object page:
- Click the Facets link from the footer section "Alternative Linked Data Views" of the page from above:
- Click "Next" to view the next of the Attributes and their Values:
- Click "Last" to view the last page of Attributes and their Values:
Paging Options
Because some Twitter API responses can return thousands of items, the following cartridge options are available to set configurable limits on the number of items returned.
(A value of 0 indicates no limit)
friends_n_followers_pg_limit:
- Limits the number of pages of friends or followers returned.
Each page can contain up to 5000 items.
(Default: 0)
friends_n_followers_item_limit:
- Overrides friends_n_followers_pg_limit.
Limits the number of friends or followers returned to the specified number where 1 < friends_n_followers_limit <= 5000.
(Default: 100)
favorites_pg_limit:
- Limits the number of pages of favorites returned.
Each page can contain up to 20 items.
(Default: 5)
user_timeline_pg_limit:
- Limits the number of tweets returned as part of a user timeline.
Each page can contain up to 20 items.
(Default: 5)
Related