使用Twitter登录时出错 [英] Error in Login With Twitter
本文介绍了使用Twitter登录时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好
以下是我用于Twitter登录的代码.
但这会产生错误:
Hello
Below is the code I am using using for Twitter login.
But it generates the errors:
No overload for method 'GetAccessToken' takes 3 arguments
和
No overload for method 'GetRequestToken' takes 2 arguments
当我这样使用
When I used like this
OAuthTokenResponse RequestToken = OAuthUtility.GetRequestToken(consumerKey, consumerSecret);
然后显示错误
then it shows the error
Cannot implicitly convert type 'Twitterizer.OAuthTokenResponse' to 'OAuthTokenResponse'
protected void imgbtnTwitter_Click(object sender, ImageClickEventArgs e)
{
// bool condition = forceLoginCheckbox.Checked;
//TwitterConsumer.StartSignInWithTwitter(condition).Send();
// add these to web.config or your preferred location
var consumerKey = ConfigurationManager.AppSettings["consumerKey"];
var consumerSecret = ConfigurationManager.AppSettings["consumerSecret"];
if (Request.QueryString["oauth_token"] == null)
{
//Step 1: Get Request Token
OAuthTokenResponse RequestToken = OAuthUtility.GetRequestToken(consumerKey, consumerSecret);
//Step 2: Redirect User to Requested Token
Response.Redirect("http://twitter.com/oauth/authorize?oauth_token=" + RequestToken.Token);
}
else
{
//For Valid User
string Oauth_Token = Request.QueryString["oauth_token"].ToString();
var accessToken = OAuthUtility.GetAccessToken(consumerKey, consumerSecret, Oauth_Token);
}
}
谁能建议使用Twitter登录的更好方法.
谢谢,
Deepak
Can anyone suggest better method for login with twitter.
Thanks,
Deepak
推荐答案
您的前两个错误是因为您向GetRequestToken
或GetAccessToken
传递了过多或不足的参数-看看它们要花多少! (如果您无法弄清这些错误的含义,那么您以前编程过吗?如果您被卡在这样的事情上,建议您尝试更简单的方法.)
这是您的代码-类型问题的错误.替换
OAuthTokenResponse RequestToken = OAuthUtility.GetRequestToken(consumerKey, consumerSecret);
与
Twitterizer.OAuthTokenResponse RequestToken = OAuthUtility.GetRequestToken(consumerKey, consumerSecret);
希望这会有所帮助,
埃德:)
Your first two errors are because you have passed too much or not enough arguments toGetRequestToken
orGetAccessToken
- look at how many they take! (If you can''t work out what those errors mean, have you ever programmed before? I suggest you try something more simple if you''re stuck on things like this.)
This is a bug with your code - types issue. Replace
OAuthTokenResponse RequestToken = OAuthUtility.GetRequestToken(consumerKey, consumerSecret);
with
Twitterizer.OAuthTokenResponse RequestToken = OAuthUtility.GetRequestToken(consumerKey, consumerSecret);
Hope this helps,
Ed :)
这篇关于使用Twitter登录时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文