What is tweet:
A tweet is a post or status update on Twitter, a microblogging service. Because Twitter only allows messages to 140 characters or less, "peep" is both a play on the message size as it is in the similarity of sound to Twitter.
Twitter Website:
The below code is sample to call twitter API from your own C# code. This is working code and can use to post directly to twitter account.
C# code to tweet:
//call twitter function
string PageURL = “URL and Message of the page”;
PostTweet(PageURL);
//Twitter function
Code Snippet
- public void PostTweet( string tweet)
- {
- try
- {
- string username = "User name of twitter";
- string password = "password of twitter account";
- // 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";
- request.ServicePoint.Expect100Continue = false; // thanks to argodev for this recent change!
- // 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();
- }
- catch (Exception ex) {/* DO NOTHING */}
- }
Hi Rahul, what example should be filled in PageURL?
ReplyDeleteThanx for fast reply
You can pass the page url in string tweet.
ReplyDeletestring tweet = "How to Clear the SharePoint Configuration Cache: http://sharepointbank.com/2010/11/how-to-clear-sharepoint-configuration.html";
Which libraries are you using?
ReplyDeleteHi.i am unable to send update to my twitter account..i am not getting any errors.please help
ReplyDelete