Twitter的API + OAuth的:不能发送状态更新,得到401 [英] Twitter API + OAuth: Can't send status updates, getting 401

查看:276
本文介绍了Twitter的API + OAuth的:不能发送状态更新,得到401的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使用Twitter的API和OAuth发送状态更新(新推文)。我使用的香农惠特利.NET code例如 http://www.voiceoftech.com/swhitley/?p= 681 (如建议对Twitter的API文档)。不过,我可以读取(GET)使用OAuth就好了,当我尝试发送通过HTTP状态更新://twitter.com/statuses/update.xml(使用POST),它会返回下列XML 401:

I'm trying to use Twitter's API and OAuth to send status updates (new Tweets). I am using Shannon Whitley .NET code example http://www.voiceoftech.com/swhitley/?p=681 (as recommended on the Twitter API docs). I can read (GET) using OAuth just fine, however when I try to send a status update via http ://twitter.com/statuses/update.xml (using a POST), it returns a 401 with the following XML:

<?xml version="1.0" encoding="UTF-8"?>
<hash>
  <request>/statuses/update.xml</request>
  <error>Read-only application cannot POST</error>
</hash>

我发誓,我已经建立了我的应用程序使用的读取和写入的Twitter的授权页面(HTTP://twitter.com/oauth/authorize)甚至说的应用程序TweeVerbs.com(发展)通过希望有能力的访问和更新您在Twitter上的数据。

I swear I have set up my application to use read and write, the authorise page at Twitter (http ://twitter.com/oauth/authorize) even says "The application TweeVerbs.com (Development) by would like the ability to access and update your data on Twitter."

然而,它仍然说:只读应用程序无法邮报。 WTF!?

Yet it's still saying "Read-only application cannot POST". WTF!?

直到我脸色发青我用Google搜索此错误消息。我发现的地方,说来添加查询字符串paremeter * oauth_access_type =写*到肚里,而我也做了Twitter的授权页面,但它仍然给了我一个401重定向URL。

I have googled this error message until I was blue in the face. I found somewhere that said to add the querystring paremeter *oauth_access_type=write* to the redirect URL which goes to the Twitter authorise page which I have done, but it still gives me a 401.


如果有帮助,这里是越来越发回并弗斯按照该OAuth的认证流程中的数据:

If it helps, here is the data that is getting sent back and firth as per the OAuth workflow:

请求是否授权令牌:

的http ://twitter.com/oauth/request_token?oauth_consumer_key=tViV8vAt4cqSKbGdPGWT7Q&oauth_nonce=2790042&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1244567068&oauth_version=1.0&oauth_signature=KzxcXN%2bQ0AJoAJ%2flQfzs8SLjC%2fQ%3d

http ://twitter.com/oauth/request_token?oauth_consumer_key=tViV8vAt4cqSKbGdPGWT7Q&oauth_nonce=2790042&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1244567068&oauth_version=1.0&oauth_signature=KzxcXN%2bQ0AJoAJ%2flQfzs8SLjC%2fQ%3d

生成授权重定向网址:

的http ://twitter.com/oauth/authorize?oauth_token=EpyBg3nJGOmtmBjRUAsqqaGHARb2F2F2VcccqHkwio&oauth_access_type=write

http ://twitter.com/oauth/authorize?oauth_token=EpyBg3nJGOmtmBjRUAsqqaGHARb2F2F2VcccqHkwio&oauth_access_type=write

是否授权屏幕信息: 应用程序TweeVerbs.com(发展)来将其在Twitter上访问和更新数据此应用程序计划使用Twitter的登录你的能力。在未来。登录,如果你想连接到非Sironfoot以外的帐户。

获取访问令牌:

的http ://twitter.com/oauth/access_token?oauth_consumer_key=tViV8vAt4cqSKbGdPGWT7Q&oauth_nonce=2016804&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1244567166&oauth_token=EpyBg3nJGOmtmBjRUAsqqaGHARb2F2F2VcccqHkwio&oauth_version=1.0&oauth_signature=%2bEVQUxUPLT%2b%2bkfaG0Vq1YJZXcAw%3d

http ://twitter.com/oauth/access_token?oauth_consumer_key=tViV8vAt4cqSKbGdPGWT7Q&oauth_nonce=2016804&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1244567166&oauth_token=EpyBg3nJGOmtmBjRUAsqqaGHARb2F2F2VcccqHkwio&oauth_version=1.0&oauth_signature=%2bEVQUxUPLT%2b%2bkfaG0Vq1YJZXcAw%3d

状态更新API调用:
网址 - HTTP://twitter.com/statuses/update.xml
POST数据 - oauth_consumer_key=tViV8vAt4cqSKbGdPGWT7Q&oauth_nonce=5707692&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1244567268&oauth_token=19130957-nb89DjZhjCAzcbHUa96yRWHqlQFQIJ0AKyXpqnHt1&oauth_version=1.0&status=HelloWorld&oauth_signature=WqA%2bWY0IxveeSJ7G3Ewy3whh1sE%3d

Status Update API call: URL - http ://twitter.com/statuses/update.xml POST data - oauth_consumer_key=tViV8vAt4cqSKbGdPGWT7Q&oauth_nonce=5707692&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1244567268&oauth_token=19130957-nb89DjZhjCAzcbHUa96yRWHqlQFQIJ0AKyXpqnHt1&oauth_version=1.0&status=HelloWorld&oauth_signature=WqA%2bWY0IxveeSJ7G3Ewy3whh1sE%3d

推荐答案

不知道问题是什么,但我删除了在Twitter上我的应用程序注册(你有微博注册应用来获取OAuth键值等等),然后重新创建它。现在,它工作正常。怪异,可能是一个与Twitter搞砸了问题。

Dunno what the problem was, but I deleted my Application registration on Twitter (You have to register apps in Twitter to get OAuth keys etc.), and then recreated it. Now it works fine. Weird, probably a problem with Twitter screwing up.

我还使用Tweetsharp( http://tweetsharp.com/ ),强烈推荐它,它有一个很好的流畅API。注:切换到Tweetsharp不是固定的,我已经切换,并有同样的问题,直到我删除,并在Twitter上重新应用注册

I'm also using Tweetsharp (http://tweetsharp.com/), highly recommend it, it's got a nice fluent API. Note: switching over to Tweetsharp wasn't the fix, I had already switched over and had the same problem until I delete and recreated app registration on Twitter.

这篇关于Twitter的API + OAuth的:不能发送状态更新,得到401的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆