SEARCH
TOOLBOX
LANGUAGES
modified on 8 August 2010 at 11:35 ••• 487 views

O2 API/TweetSharp/Script Examples

From

Jump to: navigation, search

Examples on using the O2 API/TweetSharp API

Contents

Create API

var twitterAPI = new O2TwitterAPI();
return twitterAPI;
 
//O2File:O2TwitterAPI.cs

Image:8_8_2010_7_07_47_AM_tmp2E2D.jpg

Login using Username and Password

unless there has been abuse on this account, this should return true :)

var twitterAPI = new O2TwitterAPI();
var testUser = "O2Test1"; 
var testUserPassword = "PleaseDontAbuseThisAccount";
twitterAPI.login(testUser, testUserPassword);
return twitterAPI;

Image:8_8_2010_7_16_01_AM_tmp2E3C.jpg

Login using Credentials file

This is a better way to write these scripts since the account details are not hardcoded in to the script

var fileWithCredentials = @"C:\O2\_USERDATA\TwitterAccounts.xml";
var credential = fileWithCredentials.deserialize<SecretData>().get_User("DinisCruz"); 
var twitterAPI = new O2TwitterAPI();
twitterAPI.login(credential);


Write a tweet

twitterAPI.login(testUser, testUserPassword);
return twitterAPI.update("This is my first tweet");

Image:8_8_2010_7_17_53_AM_tmp2E45.jpg


get user's timeline (his tweets)

var twitterAPI = new O2TwitterAPI();
twitterAPI.login(credential);
return twitterAPI.user_Timeline();
 
//O2File:O2TwitterAPI.cs
//O2File:ISecretData.cs
//O2Ref:Dimebrain.TweetSharp.dll

Image:8_8_2010_7_29_57_AM_tmp2E80.jpg

Showing User Timeline in a Table

var twitterAPI = new O2TwitterAPI();
twitterAPI.login(credential);
panel.add_TableList_With_Tweets("User Tweets", ()=> { return  twitterAPI.user_Timeline();});

Image:8_8_2010_7_34_26_AM_tmp2E85.jpg

MediaWiki Appliance - Powered by TurnKey Linux