简体   繁体   English

QQ OAuth 错误码

[英]QQ OAuth error code

I'm trying to use the QQ (Huge Chinese social network similar to ICQ) API which uses OAuth.我正在尝试使用使用 OAuth 的 QQ(类似于 ICQ 的巨大中文社交网络)API。 I'm reasonably familiar with OAuth, but I can only read Chinese via Google Translate.我对 OAuth 相当熟悉,但我只能通过谷歌翻译阅读中文。

I use Rails 3.0.7 and follow the instructions in the oauth gem documentation .我使用 Rails 3.0.7 并按照oauth gem 文档中的说明进行操作。

According to the QQ documentation their APP ID corresponds to oauth_consumer_key and their APP KEY is the oauth consumer secret.根据QQ 文档,他们的 APP ID 对应于 oauth_consumer_key,他们的 APP KEY 是 oauth 消费者密钥。 They also specify which URL's to use.他们还指定要使用的 URL。 So I do the following in the console:所以我在控制台中执行以下操作:

@consumer=OAuth::Consumer.new("APP ID", "APP SECRET",{:site =>
"http://openapi.qzone.qq.com", :request_token_path=>"/oauth/qzoneoauth_request_token", 
:authorize_path => "/oauth/qzoneoauth_authorize", :access_token_path => 
"/get_access_token.php"} )

That returns:那返回:

#<OAuth::Consumer:0x0000010283f6a0 @key="APP ID", @secret="APP SECRET", 
@options={:signature_method=>"HMAC-SHA1", 
:request_token_path=>"/oauth/qzoneoauth_request_token", 
:authorize_path=>"/oauth/qzoneoauth_authorize", 
:access_token_path=>"/get_access_token.php", :proxy=>nil, :scheme=>:header, 
:http_method=>:post, :oauth_version=>"1.0", :site=>"http://openapi.qzone.qq.com"}> 

Now it's time to get a request token from the server:现在是时候从服务器获取请求令牌了:

@request_token=@consumer.get_request_token

Unfortunately this returns an error code: 12005 meaning invalid url (thanks @timon-vonk).不幸的是,这会返回一个错误代码: 12005表示无效的 url(感谢@timon-vonk)。 But what's wrong with it and how do I debug this?但它有什么问题,我该如何调试呢? Here's a few more details about the request, obtained with net-http-spy :以下是有关请求的更多详细信息,通过net-http-spy获得:

@request_token=@consumer.get_request_token(
:oauth_callback => "http://ishiyou.com/qq")          
opening connection to openapi.qzone.qq.com...opened
<- "GET /oauth/qzoneoauth_request_token HTTP/1.1\r\nAccept: */*\r\nUser-Agent: 
OAuth gem v0.4.4\r\nAuthorization: OAuth 
oauth_callback=\"http%3A%2F%2Fishiyou.com%2Fqq\", 
oauth_consumer_key=\"******\", 
oauth_nonce=\"gpv3iaYb7K3tExGxxnW5bjkyvU6ms3EuL9roLwgxs4\", 
oauth_signature=\"3tgryVqRFjxoXSxnYTO%2FXuRNAU4%3D\", 
oauth_signature_method=\"HMAC-SHA1\", oauth_timestamp=\"1306933000\", 
oauth_version=\"1.0\"\r\nConnection: close\r\nHost: openapi.qzone.qq.com\r\n\r\n"
-> "HTTP/1.1 200 OK\r\n"
-> "Connection: close\r\n"
-> "Server: QZHTTP-2.13\r\n"
-> "Date: Wed, 01 Jun 2011 12:56:42 GMT\r\n"
-> "Content-Length: 17\r\n"
-> "Content-type: text/html\r\n"
-> "Cache-Control: no-cache\r\n"
-> "\r\n"
reading 17 bytes...
-> "error_code=12005\n"
read 17 bytes
Conn close

A 12005 error is usually an invalid URL. 12005 错误通常是无效的 URL。

Invalid in the sense that the URL generated is not valid, not non existent.在生成的 URL 无效,不是不存在的意义上无效。 Check what URL is generated.检查生成了什么 URL。 Also, its possible that QQ just parses the request wrong and doesn't send a 404 but a 12005 for some reason.另外,QQ也有可能只是解析请求错误,由于某种原因没有发送404而是12005。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM