• Topic
  • Discussion
  • VOS.VirtCartConfigTwitter(Last) -- Owiki? , 2018-04-13 12:05:53 Edit owiki 2018-04-13 12:05:53

    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.

    1. Register the Sponger using the Twitter Developers Application.


    2. Click "Create an app".


    3. In the presented form:
      1. Specify application name, for example: 'Sponger_{your_host_name}' ;
      2. Specify your website ;
      3. 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 ;
      4. Hatch the "Yes, I agree" check-box;
      5. Enter the "CAPTCHA" words:




      6. Finally click "Create your Twitter application" button.
    4. The application will be created and a Consumer key and secret will be generated:



    5. Now go to your local Conductor at http://your-virtuoso-host:port/conductor
    6. Go to Linked Data -> Sponger -> Extractor Cartridges:


    7. Find "Twitter v2" and click on its link in order to edit its properties:
    8. 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


    9. Enter the API key and Secret Key noted in the cartridge's "Options" field as values for options consumer key and consumer_secret:


    10. 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:

    1. Go to http://{your-virtuoso-host:port}/sponger :


    2. Click the Twitter button:


    3. Click the "Authorize app" button.
    4. 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:

    1. Access http://uriburner.com/about/html/http://twitter.com/kidehen :



    2. 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:

    1. Click the Facets link from the footer section "Alternative Linked Data Views" of the page from above:



    2. Click "Next" to view the next of the Attributes and their Values:


    3. 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