Showing posts with label Twitter. Show all posts
Showing posts with label Twitter. Show all posts

Thursday, October 8, 2009

Twitter API from C# .Net

Twitter is one of the Great and friendly site ,Twitter has an API implementation that is very simple to understand and use. if you want to friends friends timelie of user you can use that from here

- http://twitter.com/statuses/friends_timeline.rss

Ones you find the RSS of friends , you can get the 3 Keywords
1 . Statuses - what are you working on ?
2. friends_timeline - what do you need ?
3. RSS - in which format you need Rss
API supoorting in xml , json, rss, atom you can choose one of that .

Methods supported: See Twitter API

There are many objects supported, but the above format applies for only a few like Statuses, User, Direct Messages. there rest all other are mostly similar.

right now i am working on complete set of wrappers using this api, so it will be easy ,plz leave a comment if you want any help

Friday, July 17, 2009

Twitter API in C#

I used C# and WCF, but I could have just as easily used an ASMX web service. This code is fairly simple.

Note: This code will not run as listed. You have to have a password. This code has that as a shared variable, but I'm not showing that to you, seriously. I hope that this is of some help to you.



[OperationContract]
public void SubmitUserStatus(string username, string tweet)
{
// encode the username/password
string user = Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(username + ":" + password));
// determine what we want to upload as a status
byte[] bytes = System.Text.Encoding.ASCII.GetBytes("status=" + tweet);
// connect with the update page
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://twitter.com/statuses/update.xml");
// set the method to POST
request.Method = "POST";
// thanks to argodev for this recent change!
request.ServicePoint.Expect100Continue = false;
// set the authorisation levels
request.Headers.Add("Authorization", "Basic " + user);
request.ContentType = "application/x-www-form-urlencoded";
// set the length of the content
request.ContentLength = bytes.Length;
// set up the stream
Stream reqStream = request.GetRequestStream();
// write to the stream
reqStream.Write(bytes, 0, bytes.Length);
// close the stream
reqStream.Close();
}




for more information on Twitter API
Link : http://twitter.com/twitterapi
Orignally posted from this Article