the twitter usernames and passwords are stored in a database..
in every login, retrive the username and password, then try to login and tweet..
i try a sample code but it don't works...
code is hire..
public void PostTweet(string tweet)
{
try
{
string username = "username";
string password = "pwd";
// 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 */}
}
Sudhi_kpza
Member
24 Points
58 Posts
working with twitterizer
Apr 30, 2012 09:46 AM|LINK
haii..
i want to post a tweet from my website using username and password.
i am using .net 3.5.is it possible?if yes,pls how..
thanks..
ramiramilu
All-Star
95463 Points
14106 Posts
Re: working with twitterizer
Apr 30, 2012 12:28 PM|LINK
use this C# Wrapper for Twitter API - https://github.com/danielcrenna/tweetsharp
Thanks,
JumpStart
Sudhi_kpza
Member
24 Points
58 Posts
Re: working with twitterizer
Apr 30, 2012 12:48 PM|LINK
haii..
thanks for reply..
the twitter usernames and passwords are stored in a database..
in every login, retrive the username and password, then try to login and tweet..
i try a sample code but it don't works...
code is hire..
public void PostTweet(string tweet)
{
try
{
string username = "username";
string password = "pwd";
// 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 */}
}
reply pls..
thanks..
YunJiang
Participant
1124 Points
122 Posts
Re: working with twitterizer
May 02, 2012 02:08 PM|LINK
This post explains how to post message from your asp.net website to Twitter.
http://dotnetguts.blogspot.com/2009/04/twitter-posting-from-aspnet-website.html