- 论坛徽章:
- 0
|
本帖最后由 qiufeng1230 于 2012-09-05 08:35 编辑
from qqweibo import APIClient
import urllib,httplib
APP_KEY="801229414"
CALLBACK_URL="http://www.baidu.com"
APP_SECRET="48f5267fddfa55efb3165b5e786af6dc"
url = https://open.t.qq.com/cgi-bin/oa ... client_id=801229414
conn = httplib.HTTPSConnection('open.t.qq.com')
postdata = urllib.urlencode({'redirect_uri':CALLBACK_URL,'client_id':APP_KEY,'response_type':'code','action':'submit','userId':Account,'passwd' assword})
conn.request('POST','/cgi-bin/oauth2/authorize',postdata,{'Referer':url,'Content-Type': 'application/x-www-form-urlencoded'})
res = conn.getresponse()
print res.getheaders()
print 'msg===========',res.msg
print 'status===========',res.status
print 'reason===========',res.reason
print 'version===========',res.version
他的运行结果是:
https://open.t.qq.com/cgi-bin/oa ... client_id=801229414
[('content-length', '17158'), ('vary', 'Accept-Encoding'), ('server', 'nginx/0.8.51'), ('connection', 'keep-alive'), ('date', 'Tue, 04 Sep 2012 08:04:30 GMT'), ('content-type', 'text/html; charset=utf-8')]
msg=========== Server: nginx/0.8.51
Date: Tue, 04 Sep 2012 08:04:30 GMT
Content-Type: text/html; charset=utf-8
Connection: keep-alive
Vary: Accept-Encoding
Content-Length: 17158
不知道是不是postdata那里有没有问题,它并没有通过httpheader返回Location信息(location信息类似于 “ http://www.baidu.com?code=da8528a307fa2f3fa3e058d11d851d0e ” 这种)。
|
|