I have single asp.net c# page with three text boxes and a button to post the tweet.
1) Input user name
2) Input password
3) Tweet text
4) Post tweet button
Problem is that I want to post the tweet on user account. On my webpage first user will enter his user name and password. I will verify the user information from twitter and then post the tweet on his own account.
Something like this which we can do in Twitterizer.
Twitter twitter = new Twitter("username", "password", "source");
twitter.Status.Update("update");
I know that now we cannot use Twitterizer.
I have used the example mentioned on the following link but it is also not working.
Twitter: verifying username and password in C#
Sample code ///////////////////////////////////////////////////////////////////////////////////////////////////
public bool CheckTwitterCredentials(string UserName, string Password)
{
// Assume failure
bool Result = false;
// A try except block to handle any exceptions
try {
// Encode the user name with password
string UserPass = Convert.ToBase64String(
System.Text.Encoding.UTF8.GetBytes(UserName + ":" + Password));
// Create our HTTP web request object
HttpWebRequest Request =
(HttpWebRequest)WebRequest.Create("http://twitter.com/account/verify_credentials.xml");
// Set up our request flags and submit type
Request.Method = "GET";
Request.ContentType = "application/x-www-form-urlencoded";
// Add the authorization header with the encoded user name and password
Request.Headers.Add("Authorization", "Basic " + UserPass);
// Use an HttpWebResponse object to handle the response from Twitter
HttpWebResponse WebResponse = (HttpWebResponse)Request.GetResponse();
// Success if we get an OK response
Result = WebResponse.StatusCode == HttpStatusCode.OK;
} catch (Exception Ex) {
System.Diagnostics.Debug.WriteLine("Error: " + Ex.Message);
}
// Return success/failure
return Result;
}
///////////////////////////////////////////////////////////////////////////////////////////////
Now twitter has provided some libraries to work with dot net C#.
https://dev.twitter.com/resources/twitter-libraries#dotnet
.NET
• LINQ2Twitter by @joemayo (examples)
• Spring.NET Social extension for Twitter by SpringSource — A Spring.NET Social extension with connection support and an API binding for Twitter.
• TweetSharp by @danielcrenna — A .net library for Twitter API access
• Tweetinvi maintained by Linvi — a Twitter .Net C# API which has for mission to simplify the development of application for Twitter in C#. The streaming API has been used on research projects and collected around 3.2 million Tweets a day. The Twitter API has been created to be easy to implement new functionality and currently provide access to most of the functionalities. (documentation)
• Crafted.Twitter by @martbrow — A caching compatible solution - with implementations for both ASP.Net Web Forms and MVC. Making it easy to include Tweets in your website.
I have used the following library TweetinviAPI. Mentioned on following link.
https://github.com/linvi/tweetinvi/wiki/Introduction#hello-world
// Set up your credentials (https://apps.twitter.com)
Auth.SetUserCredentials("CONSUMER_KEY", "CONSUMER_SECRET", "ACCESS_TOKEN", "ACCESS_TOKEN_SECRET");
// Publish the Tweet "Hello World" on your Timeline
Tweet.PublishTweet("Hello World!");
But problem is that it is posting on my own created twitter page not on other user twitter page.
What I want is that by using the above updated libraries is there any way that User put his user name and password on my page and some detail of tweet and post a tweet on his own account.
Please advise me is this possible now or not.
Thanks
Syyed