Copyright (c) PagesJaunes 2008-2009
This is the documentation for the Twitter/Identi.ca JavaScript layer released by PagesJaunes and implemented by Disruptive Innovations. This work is released tri-licensed under MPL/GPL/LGPL.
The last version of the source is available from here. Please see the release notes to learn more about this version.
The JavaScript source file is ready to be used as a JSM JavaScript
module or a normal chrome JavaScript file. In the latter case,
commenting out the line var EXPORTED_SYMBOLS = ["TwitterHelper"];
is a good thing.
Warning: the file is not meant to be used as is inside a Web page. You will need minor tweaks to do that, a future version of the file will address that case.
Comments and suggestions on this document or on the code itself should be sent to the author.
Version 1.01, 14-apr-2009:
_postXmlRequest()
in _sendPostRequest()
Version 1.0, 06-apr-2009:
Creating a TwitterHelper object is the first thing you should do to use twitter in your own code:
var twh = new TwitterHelper(aAccount,
aPassword,
aThrobber,
aServiceStr);
where
hidden
attribute being "true"
.
When a XmlHTTPrequest is sent to the Twitter or Identi.ca API, the
attribute is removed and it's reset to its original true value when
the request is completed."twitter"
for Twitter and "identi.ca"
for Identi.caAll your calls to the TwitterHelper object to call the Twitter or Identi.ca API will result in asynchronous calls. After the completion of the request, one of two callbacks you provide will be called, depending on the success or failure of the request.
If you don't want to provide a
callback in a call, use the null
JavaScript value instead.
Success callbacks are JavaScript functions that take three parameters:
Error callbacks are JavaScript functions that take three parameters:
All calls to the Twitter or Identi.ca API takes the same first four parameters:
In the code chunks below, extra parameters (i.e. above the fifth one) that cannot be null or empty are bolden.
Retrieves the friends timeline of the authenticated user.
twh.statuses.friends_timeline(aCallback,
aErrorCallback,
aContext,
aFormat,
aSince,
aSinceId,
aCount,
aPage);
Retrieves the timeline of a given user or of the authenticated user if aUserId is null.
twh.statuses.user_timeline(aCallback,
aErrorCallback,
aContext,
aFormat,
aUserId,
aSince,
aSinceId,
aCount,
aPage);
Retrieves the list of friends of the authenticated user or of a given user if aUserId is not null.
twh.statuses.friends(aCallback,
aErrorCallback,
aContext,
aFormat,
aUserId,
aPage);
Retrieves the list of followers of the authenticated user or of a given user if aUserId is not null.
twh.statuses.followers(aCallback,
aErrorCallback,
aContext,
aFormat,
aUserId,
aPage);
Retrieves a single status.
twh.statuses.show(aCallback,
aErrorCallback,
aContext,
aFormat,
aId);
Retrieves the list of mentions of the authenticated user in the public timeline.
twh.statuses.replies(aCallback,
aErrorCallback,
aContext,
aFormat,
aSince,
aSinceId,
aPage);
Destroys a status of given id. The status must have been created by the authenticated user.
twh.statuses.destroy(aCallback,
aErrorCallback,
aContext,
aFormat,
aId);
Retrieves the public timeline.
twh.statuses.public_timeline(aCallback,
aErrorCallback,
aContext,
aFormat);
Sends a new message to Twitter or Identi.ca from the authenticated user. Warning, do NOT use a non-null aSource parameter if your twitter application is not registered by Twitter...
twh.statuses.update(aCallback,
aErrorCallback,
aContext,
aFormat,
aText,
aInReplyToStatusId,
aSource);
Retrieves information about a user. One of aUserId and aEmail parameters must not be null or empty.
twh.users.show(aCallback,
aErrorCallback,
aContext,
aFormat,
aUserId,
aEmail);
Retrieves the list of current direct messages for the authenticated user.
twh.direct_messages.inbox(aCallback,
aErrorCallback,
aContext,
aFormat,
aSince,
aSinceId,
aPage);
Retrieves the list of direct messages sent by the authenticated user.
twh.direct_messages.sent(aCallback,
aErrorCallback,
aContext,
aFormat,
aSince,
aSinceId,
aPage);
Sends a new direct message from the authenticated user.
twh.direct_messages.new(aCallback,
aErrorCallback,
aContext,
aFormat,
aUser,
aText);
Destroys a direct message sent or received by the authenticated user.
twh.direct_messages.destroy(aCallback,
aErrorCallback,
aContext,
aFormat,
aId);
Adds a new friend to the list of friends of the authenticated user.
twh.friendships.create(aCallback,
aErrorCallback,
aContext,
aFormat,
aId,
aFollow);
Removes a friend from the list of friends of the authenticated user.
twh.friendships.destroy(aCallback,
aErrorCallback,
aContext,
aFormat,
aId);
Verifies if a friendship relation exists between two users.
twh.friendships.exists(aCallback,
aErrorCallback,
aContext,
aFormat,
aUserA,
aUserB);
Retrieves the list of ids of the authenticated user's friends or of user aId if that parameter is not null.
twh.friends.ids(aCallback,
aErrorCallback,
aContext,
aFormat,
aId);
Retrieves the list of ids of the authenticated user's followers or of user aId if that parameter is not null.
twh.followers.ids(aCallback,
aErrorCallback,
aContext,
aFormat,
aId);
Verifies the credentials for the current authenticated user.
twh.account.verify_credentials(aCallback,
aErrorCallback,
aContext,
aFormat);
Ends the session for the current authenticated user. Warning, not implemented by identi.ca for the time being.
twh.account.end_session(aCallback,
aErrorCallback,
aContext,
aFormat);
Updates the delivery device for the authenticated user. Parameter aDevice must be a string: "sms" or "im" or "none".
twh.account.update_delivery_device(aCallback,
aErrorCallback,
aContext,
aFormat,
aDevice);
Updates the colors stored in the authenticated user's profile. At least one of the color parameters must be non-null.
twh.update_profile_colors(aCallback,
aErrorCallback,
aContext,
aFormat,
aBackgroundColor,
aTextColor,
aLinkColor,
aSidebarFillColor,
aSidebarBorderColor);
Retrieves the current rate limit status of the authenticated user.
twh.account.rate_limit_status(aCallback,
aErrorCallback,
aContext,
aFormat);
Update profile
Updates the profile of the current authenticated user.
twh.account.update_profile(aCallback,
aErrorCallback,
aContext,
aFormat,
aName,
aEmail,
aUrl,
aLocation,
aDescription);
Retrieves the list of favorites of the authenticated user or of user aUserIf if it is not null.
twh.favorites.favorites(aCallback,
aErrorCallback,
aContext,
aFormat,
aUserId,
aPage);
Declare a status a a favorite of the authenticated user.
twh.favorites.create(aCallback,
aErrorCallback,
aContext,
aFormat,
aId);
Removes a favorite from the list of favorites of the authenticated user.
twh.favorites.destroy(aCallback,
aErrorCallback,
aContext,
aFormat,
aId);
Enables notifications for updates from the specified user aUserId to the authenticating user.
twh.notifications.follow(aCallback,
aErrorCallback,
aContext,
aFormat,
aId);
Disabled notifications for updates from the specified user aId to the authenticating user.
twh.notifications.leave(aCallback,
aErrorCallback,
aContext,
aFormat,
aId);
Blocks the user specified in the aId parameter as the authenticating user.
twh.blocks.create(aCallback,
aErrorCallback,
aContext,
aFormat,
aId);
Unblocks the user specified in the aId parameter as the authenticating user.
twh.blocks.destroy(aCallback,
aErrorCallback,
aContext,
aFormat,
aId);
Tests the API.
twh.help.test(aCallback,
aErrorCallback,
aContext,
aFormat);
Checks if a text is a mention, i.e. if it contains the account name of the authenticated user immediately following an "@" character.
twh.isMention(aText);
where aText is a string. Answer is a boolean.
This space reserved for future use.