本文介绍了ASP.NET网站中的Twitter集成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,
我想将twitter集成到我的ASP.Net网站中,C#是我在语言背后的代码.
我想实现一个个人资料页面,用户应该可以在其中登录Twitter.单击通过Twitter注册"按钮后.我已经创建了一个Twitter应用程序,并且正在使用OAuth进行此操作.获取用户详细信息后,我想将它们添加到我的SQL Server数据库中(以便将来用户可以使用这些详细信息登录).我正在使用以下代码

使用Twitterizer;

1.字符串requestToken = OAuthUtility.GetRequestToken(消费者密钥,秘密密钥,我要在其中回叫的本地主机的路径").Token;

2. OAuthTokenResponse accessToken = OAuthUtility.GetAccessToken(消费者密钥,秘密密钥,requestToken,txtPin.Text);

3. OAuthTokens令牌=新的OAuthTokens();
4. tokens.AccessToken = accessToken.Token;
5. tokens.AccessTokenSecret = accessToken.TokenSecret;
6. tokens.ConsumerKey =我的Twitter应用程序的使用者密钥
7. tokens.ConsumerSecret =我的Twitter应用程序的消费者秘密
8. screenName = accessToken.ScreenName;
9. userID = accessToken.UserId;

现在,当我构建解决方案时,它可以成功构建,但是在运行时会出现异常.异常发生在第2行.异常是

=>远程服务器返回错误:(401)未经授权.

我已经在互联网上到处搜索了,所以请回答如果您做了这种事情,我在这里做错了吗?

Hello,
I want to integrate twitter in my ASP.Net web site, C# is my code behind language.
I want to implement a profile page in which user should be able to sign in from twitter. After clicking on "Sign Up via Twitter" Button. I have made a twitter application and i am doing this thing with OAuth. After getting user details i want to add them to my SQL Server Database(So that in future user can sign in using these details). I am using the below code

using Twitterizer;

1. string requestToken = OAuthUtility.GetRequestToken(consumer key, secret key, "Path of my localhost in which i want to call back").Token;

2. OAuthTokenResponse accessToken = OAuthUtility.GetAccessToken(consumer key, secret key, requestToken, txtPin.Text);

3. OAuthTokens tokens = new OAuthTokens();
4. tokens.AccessToken = accessToken.Token;
5. tokens.AccessTokenSecret = accessToken.TokenSecret;
6. tokens.ConsumerKey = consumer key of my twitter application
7. tokens.ConsumerSecret = consumer secret of my twitter application
8. screenName = accessToken.ScreenName;
9. userID = accessToken.UserId;

Now when i build the solution it build successfully, but gives an exception at runtime. The exception comes at Line # 2. The exception is

=> The remote server returned an error: (401) Unauthorized.

I have already search all around on the internet, so please answer if you have done this kind of stuff, am i doing something wrong here?

推荐答案



这篇关于ASP.NET网站中的Twitter集成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-27 12:21