没有任何数据可供显示
| 开源项目社区 | 当前位置 : |
|
| www.trustie.net/open_source_projects | 主页 > 开源项目社区 > adobe-air-twitter |
|
adobe-air-twitter
|
| 1 | 0 | 2 |
| 贡献者 | 讨论 | 代码提交 |
Adobe Air/JS wrapper for the Twitter APIThe Twitter Api class simplifies access to the Twitter.com REST API for Adobe AIR applications written in xhtml/js. This rich library provides access to Twitter's API's via a complete set of function calls mapped directly to the Twitter API namespaces, such as:
this.trends this.timeline this.statuses this.users this.directmessage this.friendships this.socialgraph this.account this.favorites this.notifications this.blocks this.help For a complete list see: http://apiwiki.twitter.com
ConstructorCreating an API object without passing the user/pass parameter will allow you to only call functions that do not require authentication. Otherwise an error is thrown.
No Auth
var api = new TwitterAPI(); Auth
var api = new TwitterAPI('user','pass'); Calling ConventionAll functions take an object containing the functions required parameters, and optionally a callback to be called when the operation completes or an error occurs and a callback to receive progress notifications.
var api = new TwitterAPI(user,pass);
api.namespace.function( params, complete_callback, progress_callback ); params - A javascript object containing the parameters required by the function call. All function calls are documented in the source as to the parameters they require and which are optional. For instance, a function call requiring the parameter username can be constructed like so: {username: 'foo'} or var o; o.username = 'foo';.
complete_callback - function(d) {} Receives a single parameter (d) containing information about the success/failure of the call and any related data is contained in the d.response variable as a javascript object. (Explained below)
progress_callback - function(d){} Receives periodic notifications of the progress of the operation, including a .bytesLoaded and .bytesTotal to calculate percentage complete.
Response ObjectNOTE: The data available in a response can be determined by examining the Twitter API documentation: http://apiwiki.twitter.com
Example object response
{
"success":true,
"url":"http://search.twitter.com/trends/current.json",
"error":null,
"response":{
"as_of":1243900524,
"trends":{
"2009-06-01 23:55:24":[
{
"query":"#musicmonday",
"name":"#musicmonday"
},
{
"query":"#e3",
"name":"#e3"
}
]
}
}
}Error Response object format:
{
"success":false,
"url":"http://search.twitter.com/search.json?q=kmesiab&rpp=10&page=0&geocode=",
"error":"Invalid Parameter",
"response":{
"error":"Invalid Parameter"
}
}Implementors should always inspect the d.success property to determine if the call succeeded or failed.
Example UsageGet a user's @mentions
var api = new TwitterApi('username','password');
api.statuses.mentions( {}, function(d){
if( d.success ) {
alert( d.response[0].text ); // tweet
}
});Send a tweet
var api = new TwitterApi('username','password')
api.statuses.update( {status: 'Hai Twitterrrzz!' } );
标签:
