我正在尝试实现一项功能,以便在asp.Net和C#上发布Twitter上的推文。我有访问令牌,消费者密钥,回调网址等。我有两个按钮“认证”和“发送”分别进行身份验证和发送推文。
我正在使用Twitterizer2 dll。验证和发送按钮点击不会出现任何错误,但也不会在Twitter上发布任何内容。有什么需要添加或更改的吗?请帮助。
protected void btnSendTwitterMsg_Click(object sender, EventArgs e)
{
OAuthTokens accessToken = new OAuthTokens();
accessToken.ConsumerKey = "XXXXXXXXXXXXXXXXXXXXXXXX";
accessToken.ConsumerSecret = "XXXXXXXXXXXXXXXXXXXXXXXXXX";
accessToken.AccessToken = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
accessToken.AccessTokenSecret = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
TwitterStatus.Update(accessToken, "Hello World!!");
}
protected void btnAuthenticate_Click(object sender, EventArgs e)
{
var consumerKey = "XXXXXXXXXXXXXXXXXXXX";
var consumerSecret = "XXXXXXXXXXXXXXXXXXXXXXXXXX";
var callBackUrl = "my call back url";
if (Request.QueryString["oauth_token"] == null)
{
OAuthTokenResponse RequestToken = OAuthUtility.GetRequestToken(consumerKey, consumerSecret, callBackUrl);
Response.Redirect("http://twitter.com/oauth/authorize?oauth_token=" + RequestToken.Token);
}
else
{
OAuthTokenResponse RequestToken = OAuthUtility.GetRequestToken(consumerKey, consumerSecret, callBackUrl);
string oathToken = Request.QueryString["oauth_token"].ToString();
var accessToken = OAuthUtility.GetAccessToken(consumerKey, consumerSecret, RequestToken.Token, RequestToken.VerificationString);
this.lblScreenName.Text = "Hello " + accessToken.ScreenName;
}
}
由于 勒凯什
答案 0 :(得分:1)
尝试使用Spring.net Twitter,有一个ASP.NET示例可以完全满足您的需求: http://springframework.net/social-twitter/