Class SpazTwit

SpazTwit

Defined in: spaztwit.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
SpazTwit(opts)

A Twitter API library for Javascript jQuery events raised by this library

  • 'spaztwit_ajax_error'
  • 'new_public_timeline_data' (data)
  • 'new_friends_timeline_data' (data)
  • 'error_friends_timeline_data' (data)
  • 'new_replies_timeline_data' (data)
  • 'error_replies_timeline_data' (data)
  • 'new_dms_timeline_data' (data)
  • 'error_dms_timeline_data' (data)
  • 'new_combined_timeline_data' (data)
  • 'error_combined_timeline_data' (data)
  • 'new_favorites_timeline_data' (data)
  • 'error_favorites_timeline_data' (data)
  • 'verify_credentials_succeeded' (data)
  • 'verify_credentials_failed' (data)
  • 'update_succeeded' (data)
  • 'update_failed' (data)
  • 'get_user_succeeded' (data)
  • 'get_user_failed' (data)
  • 'get_one_status_succeeded' (data)
  • 'get_one_status_failed' (data)
  • 'new_search_timeline_data' (data)
  • 'error_search_timeline_data' (data)
  • 'new_trends_data' (data)
  • 'error_trends_data' (data)
  • 'new_saved_searches_data' (data)
  • 'error_saved_searches_data' (data)
  • 'create_saved_search_succeeded' (data)
  • 'create_saved_search_failed' (data)
  • 'destroy_saved_search_succeeded' (data)
  • 'destroy_saved_search_failed' (data)
  • 'create_favorite_succeeded'
  • 'create_favorite_failed'
  • 'destroy_favorite_succeeded'
  • 'destroy_favorite_failed'
  • 'create_friendship_succeeded'
  • 'create_friendship_failed'
  • 'destroy_friendship_succeeded'
  • 'destroy_friendship_failed'
  • 'create_block_succeeded'
  • 'create_block_failed'
  • 'destroy_block_succeeded'
  • 'destroy_block_failed'
  • 'follow_succeeded'
  • 'follow_failed'
  • 'unfollow_succeeded'
  • 'unfollow_failed'
  • 'ratelimit_status_succeeded'
  • 'ratelimit_status_failed'
  • 'destroy_status_succeeded'
  • 'destroy_status_failed'
  • 'destroy_dm_succeeded'
  • 'destroy_dm_failed'

Field Summary
Field Attributes Field Name and Description
 

the default timeout value (60 seconds)

Method Summary
Method Attributes Method Name and Description
 
addFriend(user_id, onSuccess, onFailure)

 
addList(list, visibility, description)

create a new list for the authenticated user

 
addSavedSearch(search_query, onSuccess, onFailure)

Saves the search query to the Twitter servers

 
addUserToList(user, list, list_user)

add a user to a list

 
block(user_id, onSuccess, onFailure)

 

 

Removes the update items from combined newitems

 

Adds ids of array of statuses to updates

 

Checks to see if the combined timeline is finished

 

Checks to see if the combined timeline is finished

 

Checks to see if the combined timeline contains sent updates

 
destroy(id, onSuccess, onFailure)

destroy/delete a status

 
destroyDirectMessage(id, onSuccess, onFailure)

destroy/delete a direct message

<inner>  
dump(input)

 
favorite(id, onSuccess, onFailure)

 
follow(user_id, onSuccess, onFailure)

 
getAPIURL(key, urldata)

 
getCombinedTimeline(com_opts, onSuccess, onFailure)

this retrieves three different timelines.

 
getDirectMessages(since_id, count, page, processing_opts, onSuccess, onFailure)

 

returns the header string for oAuth Echo usage

 
getFavorites(page, processing_opts, onSuccess, onFailure)

 
getFollowersGraph(user_id, cursor, onSuccess, onFailure)

 

 
getFriendsGraph(user_id, cursor, onSuccess, onFailure)

 

 
getFriendsTimeline(since_id, count, page, processing_opts, onSuccess, onFailure)

Initiates retrieval of the friends timeline (all the people you are following)

 
getHomeTimeline(since_id, count, page, processing_opts, onSuccess, onFailure)

Initiates retrieval of the home timeline (all the people you are following)

 
getIncomingFriendships(cursor, onSuccess, onFailure)

 
getLastId(section)

retrieves the last status id retrieved for a given section

 
getListInfo(list, user, onSuccess, onFailure)

retrieves a given list timeline

 
getListMembers(list, user)

retrieves a given list's members

 
getLists(user, onSuccess, onFailure)

retrieves the list of lists

 
getListSubscribers(list, user)

 
getListTimeline(list, user, onSuccess, onFailure)

retrieves a given list timeline

 
getOne(id, onSuccess, onFailure)

 
getOutgoingFriendships(cursor, onSuccess, onFailure)

 
getPublicTimeline(onSuccess, onFailure)

Initiates retrieval of the public timeline.

 
getRateLimitStatus(onSuccess, onFailure)

get the current rate limit status

 
getReplies(since_id, count, page, processing_opts, onSuccess, onFailure)

 
getRetweets(id, count)

 
getSavedSearches(onSuccess, onFailure)

gets the saved searches the authenticating user has

 
getSent(since_id, count, page, onSuccess, onFailure)

 
getSentDirectMessages(since_id, page, onSuccess, onFailure)

 
getTrends(onSuccess, onFailure)

 
getUser(user_id, onSuccess, onFailure)

 
getUserTimeline(id, count, page, onSuccess, onFailure)

 

resets the combined_finished progress tracker

 

 
isMember(list, list_user, user)

 
isSubscribed(list, list_user, user)

 

 

 
openUserStream(onData, onFailure)

 

this takes an array of messages and returns one with any duplicates removed This is based on the jQuery.unique() method

 
removeExtraElements(items, max, remove_from_top)

removes extra elements from a timeline array.

 
removeFriend(user_id, onSuccess, onFailure)

 
removeList(list, user)

delete a list

 
removeSavedSearch(search_id, onSuccess, onFailure)

Delete the saved search corresponding to the given ID

 
removeUserFromList(user, list, list_user)

delete a user from a list

 
reportSpam(user_id, onSuccess, onFailure)

 
retweet(id, onSuccess, onFailure)

 
retweetedByMe(since, max, count, page)

 
retweetedToMe(since, max, count, page)

 
retweetsOfMe(since, max, count, page)

 
search(query, since_id, results_per_page, page, lang, geocode, onSuccess, onFailure)

 
setBaseURL(newurl)

sets the base URL

 

sets the base URL by the service type

 
setCredentials(auth_obj)

 
setLastId(section, id)

sets the last status id retrieved for a given section

 
setSource(new_source)

set the source string we will pass on updates

 
showFriendship(target_id, source_id, onSuccess, onFailure)

 
subscribe(list, user)

 
test()

 
triggerEvent(type, data)

 
unblock(user_id, onSuccess, onFailure)

 
unfavorite(id, onSuccess, onFailure)

 
unfollow(user_id, onSuccess, onFailure)

 
unsubscribe(list, user)

 
update(status, source, in_reply_to_status_id, onSuccess, onFailure)

 
updateList(list, name, visibility, description)

 
updateLocation(location_str, onSuccess, onFailure)

 
updateProfile(name, email, url, location, description)

 

 
verifyCredentials(onSuccess, onFailure)

Class Detail

SpazTwit(opts)

A Twitter API library for Javascript jQuery events raised by this library

  • 'spaztwit_ajax_error'
  • 'new_public_timeline_data' (data)
  • 'new_friends_timeline_data' (data)
  • 'error_friends_timeline_data' (data)
  • 'new_replies_timeline_data' (data)
  • 'error_replies_timeline_data' (data)
  • 'new_dms_timeline_data' (data)
  • 'error_dms_timeline_data' (data)
  • 'new_combined_timeline_data' (data)
  • 'error_combined_timeline_data' (data)
  • 'new_favorites_timeline_data' (data)
  • 'error_favorites_timeline_data' (data)
  • 'verify_credentials_succeeded' (data)
  • 'verify_credentials_failed' (data)
  • 'update_succeeded' (data)
  • 'update_failed' (data)
  • 'get_user_succeeded' (data)
  • 'get_user_failed' (data)
  • 'get_one_status_succeeded' (data)
  • 'get_one_status_failed' (data)
  • 'new_search_timeline_data' (data)
  • 'error_search_timeline_data' (data)
  • 'new_trends_data' (data)
  • 'error_trends_data' (data)
  • 'new_saved_searches_data' (data)
  • 'error_saved_searches_data' (data)
  • 'create_saved_search_succeeded' (data)
  • 'create_saved_search_failed' (data)
  • 'destroy_saved_search_succeeded' (data)
  • 'destroy_saved_search_failed' (data)
  • 'create_favorite_succeeded'
  • 'create_favorite_failed'
  • 'destroy_favorite_succeeded'
  • 'destroy_favorite_failed'
  • 'create_friendship_succeeded'
  • 'create_friendship_failed'
  • 'destroy_friendship_succeeded'
  • 'destroy_friendship_failed'
  • 'create_block_succeeded'
  • 'create_block_failed'
  • 'destroy_block_succeeded'
  • 'destroy_block_failed'
  • 'follow_succeeded'
  • 'follow_failed'
  • 'unfollow_succeeded'
  • 'unfollow_failed'
  • 'ratelimit_status_succeeded'
  • 'ratelimit_status_failed'
  • 'destroy_status_succeeded'
  • 'destroy_status_failed'
  • 'destroy_dm_succeeded'
  • 'destroy_dm_failed'

Parameters:
{Object} opts
various options
{Object} opts.auth Optional
SpazAuth object
{String} opts.event_mode Optional
The event mode to use ('jquery' or 'DOM'). Defaults to 'DOM'
{Object} opts.event_target Optional
the DOM element to target the event on. Defaults to document
{Number} opts.timeout Optional
length of time, in seconds, to timeout
Field Detail

DEFAULT_TIMEOUT

the default timeout value (60 seconds)

Method Detail

addFriend(user_id, onSuccess, onFailure)

Parameters:
user_id
onSuccess
onFailure

addList(list, visibility, description)

create a new list for the authenticated user

Parameters:
{string} list
The list name
{string} visibility
"public" or "private"
{string} description Optional
The list description

addSavedSearch(search_query, onSuccess, onFailure)

Saves the search query to the Twitter servers

Parameters:
{String} search_query
onSuccess
onFailure

addUserToList(user, list, list_user)

add a user to a list

Parameters:
user
list
list_user

block(user_id, onSuccess, onFailure)

Parameters:
user_id
onSuccess
onFailure

closeUserStream()

combinedNewItemsRemoveUpdates()

Removes the update items from combined newitems

combinedTimelineAddUpdates(items)

Adds ids of array of statuses to updates

Parameters:
items

{boolean} combinedTimelineFinished()

Checks to see if the combined timeline is finished

Returns:
{boolean}

{boolean} combinedTimelineHasErrors()

Checks to see if the combined timeline is finished

Returns:
{boolean}

{boolean} combinedTimelineHasUpdates()

Checks to see if the combined timeline contains sent updates

Returns:
{boolean}

destroy(id, onSuccess, onFailure)

destroy/delete a status

Parameters:
{Number|String} id
the id of the status
onSuccess
onFailure

destroyDirectMessage(id, onSuccess, onFailure)

destroy/delete a direct message

Parameters:
{Number|String} id
the id of the status
onSuccess
onFailure

<inner> dump(input)

Parameters:
input

favorite(id, onSuccess, onFailure)

Parameters:
id
onSuccess
onFailure

follow(user_id, onSuccess, onFailure)

Parameters:
user_id
onSuccess
onFailure

getAPIURL(key, urldata)

Parameters:
key
urldata

getCombinedTimeline(com_opts, onSuccess, onFailure)

this retrieves three different timelines. the event "new_combined_timeline_data" does not fire until ALL async ajax calls are made

Parameters:
com_opts
onSuccess
onFailure

getDirectMessages(since_id, count, page, processing_opts, onSuccess, onFailure)

Parameters:
since_id
count
page
processing_opts
onSuccess
onFailure

getEchoHeader(opts)

returns the header string for oAuth Echo usage

Parameters:
opts

getFavorites(page, processing_opts, onSuccess, onFailure)

Parameters:
page
processing_opts
onSuccess
onFailure

getFollowersGraph(user_id, cursor, onSuccess, onFailure)

Parameters:
user_id
cursor
onSuccess
onFailure

getFollowersList()

getFriendsGraph(user_id, cursor, onSuccess, onFailure)

Parameters:
user_id
cursor
onSuccess
onFailure

getFriendsList()

getFriendsTimeline(since_id, count, page, processing_opts, onSuccess, onFailure)

Initiates retrieval of the friends timeline (all the people you are following)

Parameters:
{integer} since_id
default is 1
{integer} count
default is 200
{integer} page
default is null (ignored if null)
processing_opts
onSuccess
onFailure

getHomeTimeline(since_id, count, page, processing_opts, onSuccess, onFailure)

Initiates retrieval of the home timeline (all the people you are following)

Parameters:
{integer} since_id
default is 1
{integer} count
default is 200
{integer} page
default is null (ignored if null)
processing_opts
onSuccess
onFailure

getIncomingFriendships(cursor, onSuccess, onFailure)

Parameters:
cursor
onSuccess
onFailure

{integer} getLastId(section)

retrieves the last status id retrieved for a given section

Parameters:
{string} section
use one of the defined constants (ex. SPAZCORE_SECTION_HOME)
Returns:
{integer} the last id retrieved for this section

getListInfo(list, user, onSuccess, onFailure)

retrieves a given list timeline

Parameters:
{string} list
user
onSuccess
onFailure

getListMembers(list, user)

retrieves a given list's members

Parameters:
{string} list
user

getLists(user, onSuccess, onFailure)

retrieves the list of lists

Parameters:
user
onSuccess
onFailure

getListSubscribers(list, user)

Parameters:
list
user

getListTimeline(list, user, onSuccess, onFailure)

retrieves a given list timeline

Parameters:
{string} list
{string} user
the user who owns this list
{function} onSuccess Optional
function to call on success
{function} onFailure Optional
function to call on failure

getOne(id, onSuccess, onFailure)

Parameters:
id
onSuccess
onFailure

getOutgoingFriendships(cursor, onSuccess, onFailure)

Parameters:
cursor
onSuccess
onFailure

getPublicTimeline(onSuccess, onFailure)

Initiates retrieval of the public timeline.

Parameters:
onSuccess
onFailure

getRateLimitStatus(onSuccess, onFailure)

get the current rate limit status

Parameters:
{Function} onSuccess
callback for success
{Function} onFailure
callback for failure

getReplies(since_id, count, page, processing_opts, onSuccess, onFailure)

Parameters:
since_id
count
page
processing_opts
onSuccess
onFailure

getRetweets(id, count)

Parameters:
id
count

getSavedSearches(onSuccess, onFailure)

gets the saved searches the authenticating user has

Parameters:
onSuccess
onFailure

getSent(since_id, count, page, onSuccess, onFailure)

Parameters:
since_id
count
page
onSuccess
onFailure

getSentDirectMessages(since_id, page, onSuccess, onFailure)

Parameters:
since_id
page
onSuccess
onFailure

getTrends(onSuccess, onFailure)

Parameters:
onSuccess
onFailure

getUser(user_id, onSuccess, onFailure)

Parameters:
user_id
onSuccess
onFailure

getUserTimeline(id, count, page, onSuccess, onFailure)

Parameters:
id
count
page
onSuccess
onFailure

initializeCombinedTracker()

resets the combined_finished progress tracker

initializeData()

isMember(list, list_user, user)

Parameters:
list
list_user
user

isSubscribed(list, list_user, user)

Parameters:
list
list_user
user

listMemberships(user)

Parameters:
user

listsSubscribedTo(user)

Parameters:
user

openUserStream(onData, onFailure)

Parameters:
onData
onFailure

{array} removeDuplicates(array)

this takes an array of messages and returns one with any duplicates removed This is based on the jQuery.unique() method

Parameters:
{array} array
an array of Twitter message objects
Returns:
{array}

removeExtraElements(items, max, remove_from_top)

removes extra elements from a timeline array.

Parameters:
{array} items
the timeline array
{integer} max
the max # of items we should have
{boolean} remove_from_top
whether or not to remove extra items from the top. default is FALSE

removeFriend(user_id, onSuccess, onFailure)

Parameters:
user_id
onSuccess
onFailure

removeList(list, user)

delete a list

Parameters:
{string} list
The list name
user

removeSavedSearch(search_id, onSuccess, onFailure)

Delete the saved search corresponding to the given ID

Parameters:
{String} search_id
Note that this is converted to a string via search_id.toString()
onSuccess
onFailure

removeUserFromList(user, list, list_user)

delete a user from a list

Parameters:
user
list
list_user

reportSpam(user_id, onSuccess, onFailure)

Parameters:
user_id
onSuccess
onFailure

retweet(id, onSuccess, onFailure)

Parameters:
id
onSuccess
onFailure

retweetedByMe(since, max, count, page)

Parameters:
since
max
count
page

retweetedToMe(since, max, count, page)

Parameters:
since
max
count
page

retweetsOfMe(since, max, count, page)

Parameters:
since
max
count
page

search(query, since_id, results_per_page, page, lang, geocode, onSuccess, onFailure)

Parameters:
query
since_id
results_per_page
page
lang
geocode
onSuccess
onFailure

setBaseURL(newurl)

sets the base URL

Parameters:
{string} newurl

setBaseURLByService(service)

sets the base URL by the service type

Parameters:
{string} service
see SPAZCORE_SERVICE_*

setCredentials(auth_obj)

Parameters:
auth_obj

setLastId(section, id)

sets the last status id retrieved for a given section

Parameters:
{string} section
use one of the defined constants (ex. SPAZCORE_SECTION_HOME)
{integer} id
the new last id retrieved for this section

setSource(new_source)

set the source string we will pass on updates

Parameters:
{string} new_source

showFriendship(target_id, source_id, onSuccess, onFailure)

Parameters:
{string|number} target_id
the target user id, or screen name if prefixed with a "@"
{string|number} source_id Optional
the surce user id, or screen name if prefixed with a "@"
{function} onSuccess Optional
success callback
{function} onFailure Optional
failure callback

subscribe(list, user)

Parameters:
list
user

test()

triggerEvent(type, data)

Parameters:
type
data

unblock(user_id, onSuccess, onFailure)

Parameters:
user_id
onSuccess
onFailure

unfavorite(id, onSuccess, onFailure)

Parameters:
id
onSuccess
onFailure

unfollow(user_id, onSuccess, onFailure)

Parameters:
user_id
onSuccess
onFailure

unsubscribe(list, user)

Parameters:
list
user

update(status, source, in_reply_to_status_id, onSuccess, onFailure)

Parameters:
status
source
in_reply_to_status_id
onSuccess
onFailure

updateList(list, name, visibility, description)

Parameters:
list
name
visibility
description

updateLocation(location_str, onSuccess, onFailure)

Parameters:
location_str
onSuccess
onFailure

updateProfile(name, email, url, location, description)

Parameters:
name
email
url
location
description

userStreamExists()

verifyCredentials(onSuccess, onFailure)

Parameters:
onSuccess
onFailure