25
1 Tweet-SQL User Documentation http://www.tweet-sql.com Version: 2.0

Tweet-SQL User Documentation

Embed Size (px)

DESCRIPTION

User manual for Tweet-SQL version 2.0 which is a Twitter client for SQL Server 2005 and above. Tweet-SQL is a Twitter Client for Microsoft SQL Server 2005 and above. Over 30 procedures allow you to leverage the Twitter API with standard TSQL. Details installation and provides a technical reference for the Tweet-SQL procedures.

Citation preview

1

Tweet-SQL User Documentation http://www.tweet-sql.com

Version: 2.0

2

Contents

Introduction - 4 Naming Conventions - 4 Installing Tweet-SQL - 5 Deploying Tweet-SQL Procedures - 5 Removing Tweet-SQL Procedures - 7 Configuring Tweet-SQL - 9 Using Tweet-SQL - 10 Procedure Reference - 12 - tweet_sts_public_timeline - 12 - tweet_sts_friends_timeline - 12 - tweet_sts_user_timeline - 13 - tweet_sts_show - 13 - tweet_sts_update - 13 - tweet_sts_replies - 14 - tweet_sts_destroy - 14 - tweet_usr_featured - 14 - tweet_usr_friends - 14 - tweet_usr_followers - 15 - tweet_usr_show - 15 - tweet_msg_direct_messages - 16 - tweet_msg_sent - 16 - tweet_msg_new - 17 - tweet_msg_destroy - 17 - tweet_frd_create - 17 - tweet_frd_destroy - 17 - tweet_frd_exists - 17 - tweet_acc_archive - 18 - tweet_acc_verify_credentials - 18 - tweet_acc_end_session - 18 - tweet_acc_update_location - 18 - tweet_acc_update_delivery_device - 18 - tweet_acc_update_profile_colors - 18 - tweet_acc_update_profile - 19 - tweet_acc_rate_limit_status - 20 - tweet_fav_favourites - 20 - tweet_fav_create - 20 - tweet_not_follow - 21 - tweet_not_leave - 21 - tweet_blk_create - 21 - tweet_blk_destroy - 21 - tweet_hlp_test - 21 - tweet_hlp_downtime_schedule - 22 - tweet_util_shortenUrl - 22 - tweet_sog_followers - 22 - tweet_sog_friends - 22 - tweet_sog_followersTable - 23 - tweet_sog_friendsTable - 23 - tweet_cfg_loginDetails - 23

3

- tweet_cfg_http_request_timeout - 23 - tweet_cfg_resultset_send - 24 - tweet_cfg_no_type_array - 24 - tweet_cfg_licensekey - 25 Function Reference - 25 - tweet_fnc_dateconvert - 25 - tweet_fnc_httpformat - 25 - tweet_fnc_urlEncode - 25

4

Introduction Tweet-SQL enables you to interact with the Twitter API with standard TSQL on Microsoft SQL Server 2005 and above. With Tweet-SQL you can easily archive your timeline, send direct messages to your followers, and of course, update your status. Leveraging the Twitter API with Tweet-SQL is as easy as writing a few lines of TSQL. Be sure to check out the example scripts on http://sqlclrnews.blogspot.com. Naming conventions All Tweet-SQL CLR procedures start with 'tweet_' and then a naming convention, indicating their classification and function, according to the official twitter API documents. http://apiwiki.twitter.com/REST+API+Documentation For example all Tweet-SQL procedures implementing the 'status' methods start with 'tweet_sts_'. Twitter API method Twitter

Classification Tweet-SQL CLR Procedure

public_timeline Status tweet_sts_public_timeline friends_timeline Status tweet_sts_friends_timeline user_timeline Status tweet_sts_user_timeline show Status tweet_sts_show update Status tweet_sts_update friends User tweet_usr_friends followers User tweet_usr_followers featured User tweet_usr_featured * show User tweet_usr_show direct_messages Direct Message tweet_msg_direct_messages send Direct Message tweet_msg_sent new Direct Message tweet_msg_new destroy Direct Message tweet_msg_destroy create Friendship tweet_frd_create destroy Friendship tweet_frd_destroy exists Friendship tweet_frd_exists verify_credentials Account tweet_acc_verify_credentials end_session Account tweet_acc_end_session archive Account tweet_acc_archive * update_location Account tweet_acc_update_location * update_delivery_device Account tweet_acc_update_delivery_device update_profile_colors Account tweet_acc_update_profile_colors update_profile Account tweet_acc_update_profile rate_limit_status Account tweet_acc_rate_limit_status favourites Favourite tweet_fav_favourites create Favourite tweet_frd_create destroy Favourite tweet_frd_destroy follow Notification tweet_not_follow

5

leave Notification tweet_not_leave create Block tweet_blk_create destroy Block tweet_blk_destroy test Help tweet_hlp_test downtime_schedule Help tweet_hlp_downtime_schedule * ids (followers) Social Graph tweet_sog_followers ids (friends) Social Graph tweet_sog_friends ids (followers) Social Graph tweet_sog_followersTable ids (friends) Social Graph tweet_sog_friendsTable * Procedures for Twitter depreciated API methods. These may cease to function at any time. Do not use in new projects. There are also a number of procedures you can use to configure Tweet-SQL inside TSQL scripts. These use the naming convention of "tweet_cfg_<function>". Installing Tweet-SQL Tweet-SQL should be installed on the SQL Server you intend to use the procedures on. Please ensure you install Tweet-SQL under an administrator account. To install double click the "Tweet-SQL Setup.msi" file and follow the on screen instructions. After installing Tweet-SQL the procedures need to be deployed to a local SQL Server instance and the settings configured. The .Net Framework 2 or above is required. Deploying Tweet-SQL Procedures Tweet-SQL procedures need to be deployed to a database hosted on SQL Server. Ensure you install as a sysadmin and you are the owner of the selected database. In the Tweet-SQL Configuration Program click the "Tweet-SQL" menu item in the main Menu.

6

• Click "Deploy" • Choose a Local SQL Server instance to log on to.

• Choose Windows or SQL Server Authentication (enter a valid SQL Server login) and click "Connect".

• In the next screen choose or database to install Tweet-SQL in. (You may also create a new database if you wish.)

• Click "Next".

7

• Click "Install" to deploy Tweet-SQL. This may take a few moments.

• Click "Finish" once complete. Removing Tweet-SQL Procedures

• In the Tweet-SQL Configuration Program click Tweet-SQL > Remove. • Log on to the Local SQL Server Instance you wish to remove the Tweet-SQL

procedures from.

8

• Click "Connect" • Select the database to remove Tweet-SQL from.

N.B. By checking "Also Disable SQL CLR" all CLR functionality on the SQL Server will be disabled.

• Click "Next". • Click "Remove".

9

• Click "Finish" to exit this window.

Configuring Tweet-SQL Tweet-SQL can be configured through the Tweet-SQL Configuration program, included in the installation, or through the provided Stored Procedures.

Tweet-SQL Configuration Stored Procedures The following stored procedures are available to adjust the settings of Tweet-SQL. Proc Name Comment Example Tips tweet_cfg_loginDetails Change the twitter account

Tweet-SQL uses. EXEC dbo.tweet_cfg_loginDetails 'joebloggs', 'secret';

tweet_cfg_http_request_timeout Change the http request timeout value (ms).

EXEC dbo.tweet_cfg_http_request_timeout 60000;

A minimum value of 15000 is recommended.

tweet_cfg_resultset_send Change the way Tweet-SQL returns responses to you.

EXEC dbo.tweet_cfg_resultset_send 1; 0 - Disables the sending of resultsets. Only the @xml output variable is used 1 - Sends the resultset broken up logically into tables. (often multiple resultsets). 2 - Send a single-column resultset containing the raw xml;

tweet_cfg_no_type_array Omit the type array table returned in some responses.

EXEC dbo.tweet_cfg_no_type_array 1; 0 - returned the type array in the returned resultsets (if applicable). 1 - omitts the type array from the resultsets. (if applicable).

tweet_cfg_licensekey Change the license key for Tweet-SQL.

EXEC dbo.tweet_cfg_licensekey '1234567890';

Twitter login details.

Control how resultsets are presented.

Specify if the “type” array in some resultsets is returned.

The timeout for HTTP requests. (milliseconds).

Tweet-SQL serial key.

10

Using Tweet-SQL Tweet-SQL uses XML output variables to provide flexibility in how Twitter data can be handled. You can instead use the various settings available in Tweet-SQL to return differently formatted resultsets but a null output parameter needs to be included. The Tweet-SQL examples shown here have been executed in SQL Server Management Studio (SSMS). First run the Tweet-SQL Configuration Program and ensure the "Result Type" is set to "No ResultSets". Run the below T-SQL in SSMS... DECLARE @xml XML; -- Declare an xml variable EXEC dbo.tweet_sts_public_timeline @xml OUTPUT; -- Execute the procedure SELECT @xml AS twitter_response; -- View the contents of the xml variable The following data will be returned.

SSMS will display a nicely formatted XML document if you click on the blue hyper-linked resultset returned by Tweet-SQL.

Next go back to the Tweet-SQL Configuration Program and change "Result Type" to "Relational Resultsets". Execute the below T-SQL in SSMS... EXEC dbo.tweet_sts_public_timeline null; -- supply a null parameter The following data will be returned...

11

Note: The public timeline will include an extra resultset if you do not choose to omit it. This is the "type array" returned by twitter and displayed by Tweet-SQL like below.

Please note that Tweet-SQL may return more than one resultset depending on the call made. Consult your programming language's documentation for information on how to deal with multiple resultsets in a single call. Hint: ADO.Net has the NextRecordSet() method, the PHP extension PDO_ODBC has the nextRowset() method, while Java has the getMoreResults() method.

12

Procedure Reference tweet_sts_public_timeline - @xml OUTPUT Returns the 20 most recent statuses from non-protected users who have set a custom user icon. Does not require authentication. Note that the public timeline is cached for 60 seconds so requesting it more often than that is a waste of resources. The API limit is not applicable for the public timeline method.

Calling the public timeline to return relational resultsets; EXEC dbo.tweet_sts_public_timeline null; Calling the public timeline using OUTPUT parameters; DECLARE @xml XML; EXEC dbo.tweet_sts_public_timeline @xml OUTPUT; SELECT @xml; tweet_sts_friends_timeline - @optional INPUT, @xml OUTPUT Returns the 20 most recent statuses posted by the authenticating user and that user's friends. This is the equivalent of /home on the Web. API usage consumes 1 for each request. Basic usage; EXEC dbo.tweet_sts_friends_timeline null, null; The @optional parameter can be used for multiple twitter parameters each with a different functions.

• since. Optional. Narrows the returned results to just those statuses created after the specified HTTP-formatted date, up to 24 hours old. The same behaviour is available by setting an If-Modified-Since header in your HTTP request.

EXEC dbo.tweet_sts_friends_timeline null, '?since=Sat%2C+11+Oct+2008+00%3A55%3A48+GMT', null;

• since_id. Optional. Returns only statuses with an ID greater than (that is, more recent than) the specified ID.

EXEC dbo.tweet_sts_friends_timeline '?since_id=955223288', null;

• count. Optional. Specifies the number of statuses to retrieve. May not be greater than 200.

EXEC dbo.tweet_sts_friends_timeline '?count=2', null;

• page. Optional. Request a specific page of the friends timeline.

13

EXEC dbo.tweet_sts_friends_timeline '?page=3', null; tweet_sts_user_timeline - @user_id_or_nick INPUT, @optional INPUT, @xml OUTPUT Returns the 20 most recent statuses posted from the authenticating user. It's also possible to request another user's timeline via the @user_id_or_nick parameter. This is the equivalent of the Web /archive page for your own user, or the profile page for a third party. Basic usage. -- Returns page 1 of the authenticating users timeline EXEC dbo.tweet_sts_user_timeline null, null, null; Usage with the @optional parameter.

• count. Optional. Specifies the number of statuses to retrieve. May not be greater than 200.

-- Returns the last 200 statuses from the authenticating users timeline EXEC dbo.tweet_sts_user_timeline null, '?count=200', null;

• since. Optional. Narrows the returned results to just those statuses created after the specified HTTP-formatted date, up to 24 hours old.

-- Returns the statuses since the http formatted date, up to 24 hours old EXEC dbo.tweet_sts_user_timeline null, '?since=Sat%2C+25+Oct+2008+00%3A55%3A48+GMT', null;

• since_id. Optional. Returns only statuses with an ID greater than (that is, more recent than) the specified ID.

-- Returns the statuses with an id greater than the one specified EXEC dbo.tweet_sts_user_timeline null, '?since_id=975128621', null;

• page. Optional. Requests a specific page. -- Request a specific page of the authenticating users timeline EXEC dbo.tweet_sts_user_timeline null, '?page=2', null; tweet_sts_show - @status_id INPUT, @xml OUTPUT Returns a single status, specified by the status_id parameter. EXEC dbo.tweet_sts_show 913184971, null; tweet_sts_update - @status INPUT, @xml OUTPUT Updates the authenticating user's status. EXEC dbo.tweet_sts_update 'writing documentation for Tweet-SQL!', null; tweet_sts_replies - @optional INPUT, @xml OUTPUT

14

Returns the 20 most recent @replies (status updates prefixed with @username) for the authenticating user. Basic usage. EXEC dbo.tweet_sts_replies null, null; Usage with the @optional parameter.

• page. Optional. Retrieves the 20 next most recent replies. EXEC dbo.tweet_sts_replies '?page=1', null;

• since. Optional. Narrows the returned results to just those replies created after the specified HTTP-formatted date, up to 24 hours old.

EXEC dbo.tweet_sts_replies '?since=Sat%2C+11+Oct+2008+00%3A55%3A48+GMT', null;

• since_id. Optional. Returns only statuses with an ID greater than (that is, more recent than) the specified ID.

EXEC dbo.tweet_sts_replies '?since_id=123456', null; tweet_sts_destroy - @status_id INPUT, @xml OUTPUT Destroys the status specified by the required status_id parameter. The authenticating user must be the author of the specified status. EXEC dbo.tweet_sts_destroy 946054908, null; tweet_user_featured - @xml OUTPUT This procedure is deprecated and may cease to function at any time. Do not use in new projects. tweet_usr_friends - @user_id_or_nick INPUT, @optional INPUT, @xml OUTPUT Returns up to 100 of the authenticating user's friends who have most recently updated, each with current status inline. It's also possible to request another user's recent friends list via the user_id_or_nick parameter. To get the authenticating users friends. EXEC dbo.tweet_usr_friends null, null, null; To request another users friends list. EXEC dbo.tweet_usr_friends '16328110', null, null;

15

Usage with the @optional parameter.

• page. Optional. Retrieves the next 100 friends. EXEC dbo.tweet_usr_friends '16328110', '?page=2', null;

• since. Optional. Narrows the returned results to just those friendships created after the specified HTTP-formatted date, up to 24 hours old. The same behaviour is available by setting an If-Modified-Since header in your HTTP request. EXEC dbo.tweet_usr_friends '16328110', '?since=Sat%2C+11+Oct+2008+00%3A55%3A48+GMT', null;

tweet_usr_followers - @user_id_or_nick INPUT, @optional INPUT, @xml INPUT Returns the authenticating user's followers, each with current status inline. Basic usage. Will return the authenticating users followers. EXEC dbo.tweet_usr_followers null, null, null; Return a specific users followers. EXEC dbo.tweet_usr_followers '16328110', null, null; Usage with the @optional parameter.

• page. Optional. Retrieves the next 100 followers. EXEC dbo.tweet_usr_followers '16328110', '?page=2', null; tweet_usr_show - @user_id_or_nick INPUT, @optional INPUT, @xml INPUT Returns extended information of a given user, specified by ID or screen name as per the required user_id_or_nick parameter. You must be properly authenticated to request the page of a protected user. Basic usage. EXEC dbo.tweet_usr_show 'rhyscampbell', null, null; or EXEC dbo.tweet_usr_show '14370206', null, null; Usage with the @optional parameter.

• email. Optional. The email address of a user. * This parameter is depreciated EXEC dbo.tweet_usr_show null, '[email protected]', null;

16

tweet_msg_direct_messages - @optional INPUT, @xml OUTPUT Returns a list of the 20 most recent direct messages sent to the authenticating user. Basic usage. EXEC dbo.tweet_msg_direct_messages null, null; Usage with the @optional parameter.

• since. Optional. Narrows the resulting list of direct messages to just those sent after the specified HTTP-formatted date, up to 24 hours old.

EXEC dbo.tweet_msg_direct_messages '?since=Sat%2C+11+Oct+2008+00%3A55%3A48+GMT', null;

• since_id. Optional. Returns only direct messages with an ID greater than (that is, more recent than) the specified ID.

EXEC dbo.tweet_msg_direct_messages '?since_id=38296659', null;

• page. Optional. Retrieves the 20 next most recent direct messages. EXEC dbo.tweet_msg_direct_messages '?page=1', null; tweet_msg_sent - @optional INPUT, @xml OUTPUT Returns a list of the 20 most recent direct messages sent by the authenticating user. Basic usage. EXEC dbo.tweet_msg_sent null, null; Usage with the @optional parameter.

• since. Optional. Narrows the resulting list of direct messages to just those sent after the specified HTTP-formatted date, up to 24 hours old.

EXEC dbo.tweet_msg_sent '?since=Sat%2C+11+Oct+2008+00%3A55%3A48+GMT', null;

• since_id. Optional. Returns only sent direct messages with an ID greater than (that is, more recent than) the specified ID.

EXEC dbo.tweet_msg_sent '?since_id=38297036', null;

• page. Optional. Retrieves the 20 next most recent direct messages sent. EXEC dbo.tweet_msg_sent '?page=2', null; tweet_msg_new - @user_id_or_nick INPUT, @mesage INPUT, @xml OUTPUT

17

Sends a new direct message to the specified user from the authenticating user. Requires the user_id_or_nick, message and xml parameters below. Returns the sent message when successful. EXEC dbo.tweet_msg_new 'rhyscampbell', 'This is a test message!', null; tweet_msg_destroy - @id INPUT, @xml OUTPUT Destroys the direct message specified in the required ID parameter. The authenticating user must be the recipient of the specified direct message. The deleted message is returned when successful. EXEC dbo.tweet_msg_destroy 38296660, null; tweet_frd_create - @user_id_or_nick INPUT, @xml OUTPUT Befriends the user specified in the ID parameter as the authenticating user. Returns the befriended user when successful. Basic usage. -- Befriend a user by screen name EXEC dbo.tweet_frd_create 'test', null; -- Befriend a user by id EXEC dbo.tweet_frd_create 123456, null; tweet_frd_destroy - @user_id_or_nick INPUT, @xml OUTPUT Discontinues friendship with the user specified in the ID parameter as the authenticating user. Returns the un-friended user in the requested format when successful. Basic usage. -- Unfriend a user by screen name EXEC dbo.tweet_frd_destroy 'test', null; -- Unfriend a user by id EXEC dbo.tweet_frd_destroy 12345, null; tweet_frd_exists - @user_a INPUT, @user_b INPUT, @xml OUTPUT Tests if a friendship exists between two users. Basic usage. EXEC dbo.tweet_frd_exists 'user_a', 'user_b', null; tweet_acc_archive - @xml OUTPUT

18

This procedure is deprecated and may cease to function at any time. Do not use in new projects. tweet_acc_verify_credentials - @xml OUTPUT Use this procedure to test if supplied user credentials are valid with minimal overhead. Returns user information for the authenticating credentials. Basic usage. EXEC dbo.tweet_acc_verify_credentials null; tweet_acc_end_session - @xml OUTPUT Ends the session of the authenticating user. Basic uage. EXEC dbo.tweet_acc_end_session; tweet_acc_update_location - @location INPUT, @xml OUTPUT * This method is depreciated. Use tweet_acc_update_profile instead. Updates the location attribute of the authenticating user. Basic usage. EXEC dbo.tweet_acc_update_location 'London', null; tweet_acc_update_delivery_device - @device INPUT, @xml OUTPUT Sets which device Twitter delivers updates to for the authenticating user. Sending none as the device parameter will disable IM or SMS updates. The @device parameter must be one of 'sms', 'im' or 'none'. Basic usage. EXEC dbo.tweet_acc_update_delivery_device 'im', null; -- instant messenger updates EXEC dbo.tweet_acc_update_delivery_device 'sms', null; -- sms updates EXEC dbo.tweet_acc_update_delivery_device 'none', null; -- disables im or sms updates tweet_acc_update_profile_colors - @profile_background_color INPUT, @profile_text_color INPUT, @profile_link_color INPUT, @profile_sidebar_fill_color INPUT, @profile_sidebar_border_color INPUT, @xml OUTPUT Controls the colour scheme of the authenticating user’s profile. Each parameter's value must be a valid hexadecimal value, and may be either three or six characters (ex: #fff or #ffffff). At

19

least one colour value must be supplied when the procedure is called. If a null value is entered for a parameter then the procedure will not attempt to update the corresponding colour value. Basic usage. -- Set Twitter profile background to Black EXEC dbo.tweet_acc_update_profile_colors '000000', null, null, null, null, null; -- Updates backgroup to the Twitter default EXEC dbo.tweet_acc_update_profile_colors '9AE4E8', null, null, null, null, null; tweet_acc_update_profile - @name INPUT, @email INPUT, @profile_url INPUT, @location INPUT, @description INPUT, @xml OUTPUT Updates values editable on the Twitter website under the ‘Account’ tab. If a null value is entered for a parameter then the procedure will not attempt to update the corresponding colour value, i.e. Supplying “Joe Bloggs” for the name and NULL for the remaining values will not change any value other than name. The remove the contents of a field you must specify a space character. Basic Usage. -- Updates the authenticating users profile -- name to "Joe Bloggs". No other profile -- fields are updated EXEC dbo.tweet_acc_update_profile 'Joe Bloggs', null, null, null, null, null; -- Update the authenticating users one-line bio DECLARE @description VARCHAR(160); SET @description = 'SQL Server & MySQL Guy, Tech & Beer Lover' EXEC dbo.tweet_acc_update_profile null, null,

20

null, null, @description, null; tweet_acc_rate_limit_status - @xml OUTPUT Returns the remaining number of API requests available to the authenticating user before the API limit is reached for the current hour. Calls to rate_limit_status will not count against the rate limit. Basic usage. EXEC dbo.tweet_acc_rate_limit_status null; tweet_fav_favourites - @user_id_or_nick INPUT, @optional INPUT, @xml OUTPUT Returns the 20 most recent favorite statuses for the authenticating user or user specified by the user_id_or_nick parameter. Basic usage. -- Return the authenticating users last 20 favourites EXEC dbo.tweet_fav_favourites null, null, null; -- Return favs for the 'lost_in_bangkok' user EXEC dbo.tweet_fav_favourites 'lost_in_bangkok', null, null; -- Return favs using a twitter user id EXEC dbo.tweet_fav_favourites 14370206, null, null; Usage with the @optional parameter.

• page. Optional. Retrieves the 20 next most recent favourite statuses. -- Request page 2 favs for a user EXEC dbo.tweet_fav_favourites 14370206, '?page=2', null; tweet_fav_create - @id INPUT, @xml OUTPUT Favourites the status specified in the ID parameter as the authenticating user. Returns the favourite status when successful. Basic usage. EXEC dbo.tweet_fav_create 964272975, null; tweet_not_follow - @user_id_or_nick INPUT, @xml OUTPUT

21

Enables notifications for updates from the specified user to the authenticating user. Returns the specified user when successful. You must already be friends with a user to use this action otherwise an error is returned. Basic usage. EXEC dbo.tweet_not_follow 'twitter', null; tweet_not_leave - @user_id_or_nick INPUT, @xml OUTPUT Disables notifications for updates from the specified user to the authenticating user. Returns the specified user when successful. You must already be friends with a user to use this action otherwise an error is returned. Basic usage. -- Disable status update notifications from a specific user EXEC dbo.tweet_not_leave 16328110, null; tweet_blk_create - @user_id_or_nick INPUT, @xml OUTPUT Blocks the user specified in the user_id_or_nick parameter as the authenticating user. Returns the blocked user in the requested format when successful. Basic usage. EXEC dbo.tweet_blk_create 16328110, null; tweet_blk_destroy - @user_id_or_nick INPUT, @xml OUTPUT Un-blocks the user specified in the user_id_or_nick parameter as the authenticating user. Returns the un-blocked user in the requested format when successful. Basic usage. EXEC dbo.tweet_blk_destroy 16328110, null; tweet_hlp_test - @xml OUTPUT Returns the string "ok". Basic usage. EXEC dbo.tweet_hlp_test null; tweet_hlp_downtime_schedule - @xml OUTPUT

22

This procedure is deprecated and may cease to function at any time. Do not use in new projects. tweet_util_shortenUrl - @long_url, @short_url OUTPUT Returns a TinyURL for the @long_url value or null upon failure. No attempt will be made to shorten urls less than 30 characters and the procedure will return the @long_url value for @short_url. Basic usage. DECLARE @long_url NVARCHAR(1000), @short_url NVARCHAR(100); SET @long_url = 'http://rover.ebay.com/rover/1/711-53200-19255-0/1?type=3&campid=5336224516&toolid=10001&customid=tiny-hp&ext=unicycle&satitle=unicycle' -- Make the long url short! EXEC dbo.tweet_util_shortenUrl @long_url, @short_url OUTPUT; SELECT @short_url; tweet_sog_followers - @user_id_or_nick INPUT, @xml OUTPUT Returns the ids of the authenticating users followers or, if a non-null value is supplied for @user_id_or_nick, the ids of the specified user’s followers. Basic usage. -- Return the authenticating users follower ids EXEC dbo.tweet_sog_followers null, null; -- Return the specified nick's follower ids EXEC dbo.tweet_sog_followers 'stephenfry', null; -- Return the specified user id follower ids EXEC dbo.tweet_sog_followers 14370206, null; tweet_sog_friends - @user_id_or_nick INPUT, @xml OUTPUT Returns the ids of the authenticating users friends or, if a non-null value is supplied for @user_id_or_nick, the ids of the specified user’s friends. Basic usage. -- Return the authenticating users friends ids EXEC dbo.tweet_sog_friends null, null; -- Return the specified nick's friends ids EXEC dbo.tweet_sog_friends 'stephenfry', null; -- Return the specified user id friends ids EXEC dbo.tweet_sog_friends 14370206, null;

23

tweet_sog_followersTable - @user_id_or_nick INPUT Returns the same data from tweet_sog_followers but saves it to a table in the SQL Server database Tweet-SQL is hosted in. The table created is called tweet_followersIds. Any existing table with this name is dropped at the start of the procedure execution. Basic usage. -- The authenticating users followers ids in a local table EXEC dbo.tweet_sog_followersTable null; -- The specified nick's followers ids in a local table EXEC dbo.tweet_sog_followersTable 'stephenfry'; -- The specified user id followers ids in a local table EXEC dbo.tweet_sog_followersTable 14370206; -- View the table data SELECT * FROM dbo.tweet_followersIds tweet_sog_friendsTable - @user_id_or_nick INPUT Returns the same data from tweet_sog_friends but saves it to a table in the SQL Server database Tweet-SQL is hosted in. The table created is called tweet_friendsIds. Any existing table with this name is dropped at the start of the procedure execution. Basic usage. -- The authenticating users friends ids in a local table EXEC dbo.tweet_sog_friendsTable null; -- The specified nick's friends ids in a local table EXEC dbo.tweet_sog_friendsTable 'stephenfry'; -- The specified user id friends ids in a local table EXEC dbo.tweet_sog_friendsTable 14370206; -- View the table data SELECT * FROM dbo.tweet_friendsIds tweet_cfg_loginDetails - @username_or_email INPUT, @password INPUT This procedure allows the login details for twitter to be changed. Basic usage. EXEC dbo.tweet_cfg_loginDetails '[email protected]', 'secret'; tweet_cfg_http_request_timeout - @milliSeconds INPUT This procedure allows you to adjust the default http request timeout used by Tweet-SQL. Please note the timeout value is expressed as milliseconds. Basic usage.

24

EXEC dbo.tweet_cfg_http_request_timeout 30000; tweet_cfg_resultset_send - @resultset_send INPUT This procedure allows you to modify the way results are returned by Tweet-SQL. The resultset_send parameter allows values of 0, 1 and 2 only. Basic usage. -- Disables the sending of resultsets. -- Only the @xml output variable is used to return results. EXEC dbo.tweet_cfg_resultset_send 0; -- Sends the resultset broken up logically into tables. -- (often multiple resultsets). EXEC dbo.tweet_cfg_resultset_send 1; -- Send a single-column resultset containing the returned xml. EXEC dbo.tweet_cfg_resultset_send 2; This procedure will return some help if you enter an invalid value for @resultset_send -- Enter an invalid number to get help EXEC dbo.tweet_cfg_resultset_send 5; The following help text will be returned... The resultset_send parameter must be one of the following values... 0 : Disables the sending of resultsets. Only the @xml output variable is used to return results. 1 : Sends the resultset broken up logically into tables. (often multiple resultsets). 2 : Send a single-column resultset containing the returned xml. tweet_cfg_no_type_array - @no_type_array INPUT This procedure allows you to include, or omit, the "type array" returned by twitter for some method calls. The @no_type_array parameter will only accept values of 0 or 1, returning help text otherwise. Basic usage. -- Include the "type array" in resultsets EXEC dbo.tweet_cfg_no_type_array 0; -- Omit the type array from resultset EXEC dbo.tweet_cfg_no_type_array 1; This procedure will return some help if you enter an invalid value for @no_type_array. -- Enter an invalid number to get help EXEC dbo.tweet_cfg_no_type_array 5; The following help text will be returned...

25

The no_type_array parameter must be one of the following values... 0 : The type array table is returned with the resultset(s). 1 : The type array table is omitted from the resultset(s). tweet_cfg_licensekey- @licence_key INPUT This procedure allows you to update the license key used for Tweet-SQL. Basic usage. EXEC dbo.tweet_cfg_licensekey '1234567890'; Function Reference tweet_fnc_dateconvert - @httpDateTime This function is for transforming Twitter returned http formatted datetime strings into something more suitable for SQL Server. The function will attempt to return a OBDC canonical formatted datetime value for the provided input and will return NULL upon failure. Basic usage. SELECT dbo.tweet_fnc_dateconvert('Mon Oct 20 21:01:51 +0000 2008'); tweet_fnc_httpformat - @datetime This function is for converting datetime values into their http formatted equivalents. NULL is returned on failure. Basic usage. SELECT dbo.tweet_fnc_httpformat(GETDATE());. tweet_fnc_urlEncode - @query This function url encodes user inputted strings. NULL is returned on failure. Basic usage. SELECT dbo.tweet_fnc_urlEncode('Wed, 04 Mar 2009 19:47:10 GMT');