Thursday, November 5, 2009

Twitter API Library – Build 4

I’m going to post status updates on the Twitter API Library, despite the fact
that I don’t think anyone is using it yet.  I’ll post Change Logs to the blog.

URI:
http://sandbox.gtaero.net/twitter_api/code.php?b=4
(Preview level Code)

  • Addition of Read-Only “Quick Variables” for easy access.
    • $twitter->uid – Logged In User’s ID.
    • $twitter->name
      – Logged In User’s Full Name.
    • $twitter->screen_name – Logged In User’s Screen
      Name.
    • $twitter->first_name – Logged In User’s First Name (generated).

    • $twitter->last_name – Logged In User’s Last Name (generated).

  • Changes to $twitter->require_login() process (happens once per
    session):
    1. $twitter->require_login() is called.
    2. OAuth Data
      is Gathered from Twitter’s Server.
    3. User is Redirected to Twitter OAuth Authorization
      Page.
    4. OAuth Redirects User to Call Back Page (which should include or BE Twitter.php)
    5. Twitter API Library automatically redirects to page that called require_login() with
      OAuth Token
    6. $twitter->require_login() is called.
    7. OAuth
      Authorized Tokens are Stored and page is refreshed automatically without the OAuth Token in the URI.

      • Authorization Tokens can then be called for storage using
        list($token_key,$token_secret)
        = $twitter->get_login().
      • If Authorization Tokens have been stored, entire
        process can be skipped using $twitter->use_login($token_key,$token_secret);

    8. $twitter->api->account_verifyCredentials() is called and the result is
      cached.
    9. Quick Variables are created.
  • First
    Preview of “TWML” or
    Twitter Markup Language.
    • TWML should be called with $tw = new
      TWML($twitter);
    • Created
      Tag: $tw->name([ int $uid = NULL [, array $options ] ] )
      Supported Options:

      • linked = true (link to profile)
      • useyou = true (display “you” instead of
        name if logged in user)
      • firstnameonly
        = false (only display first name)
      • lastnameonly = false (only display last name (if available, else first))

      • screennameonly = false (only display screen name)
      • possessive = false (use possessive case,
        e.g. “your”)
      • reflexive =
        false (use reflexive case, e.g. “yourself”)
      • style="background-color: #ffffff">capitalize = false (capitalize if not a name, e.g. “Your”)
      • subjectid = NULL

  • Added
    $twitter->api->call_amount() which returns the amount of requests made to twitter (this
    instance).

Known Issues:


  • No Support for Unauthenticated Requests
  • $tw->name() does
    not support users other than the currently logged in user.