Quantcast
Channel: liujusmartclient Issue Tracker Rss Feed
Viewing all articles
Browse latest Browse all 16

Closed Feature: 获取AccessToken [8802]

$
0
0
获取access token
 
新浪微博开放平台access token请求地址为:http://api.t.sina.com.cn/oauth/access_token
以下是请求参数列表:
oauth_consumer_key - GDdmIQH6jhtmLUypg82g
oauth_nonce - 9zWH6qe0qG7Lc1telCn7FhUbLyVdjEaL3MO5uHxn8
oauth_signature_method - HMAC-SHA1
oauth_token - 8ldIZyxQeVrFZXFOZH5tAwj6vzJYuLQpl0WUEYtWc
oauth_timestamp - 1272323047
oauth_verifier - pDNg57prOHapMbhv25RNf75lVRd6JDsni1AJJIDYoTY
oauth_version - 1.0
oauth_token_secret - x6qpRnlEmW9JbQn4PQVVeVG8ZLPEx6A0TOebgwcuA
第一步,准备base string(使用上文提到的方法)
POST&https%3A%2F%2Fapi.t.sina.com.cn%2Foauth%2Faccess_token&oauth_consumer_key%3DGDdmIQH6jhtmLUypg82g%26oauth_nonce%3D9zWH6qe0qG7Lc1telCn7FhUbLyVdjEaL3MO5uHxn8%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1272323047%26oauth_token%3D8ldIZyxQeVrFZXFOZH5tAwj6vzJYuLQpl0WUEYtWc%26oauth_verifier%3DpDNg57prOHapMbhv25RNf75lVRd6JDsni1AJJIDYoTY%26oauth_version%3D1.0
 
POST
&https%3A%2F%2Fapi.t.sina.com.cn%2Foauth%2Faccess_token
&oauth_consumer_key%3DGDdmIQH6jhtmLUypg82g
%26oauth_nonce%3D9zWH6qe0qG7Lc1telCn7FhUbLyVdjEaL3MO5uHxn8
%26oauth_signature_method%3DHMAC-SHA1
%26oauth_timestamp%3D1272323047
%26oauth_token%3D8ldIZyxQeVrFZXFOZH5tAwj6vzJYuLQpl0WUEYtWc
%26oauth_verifier%3DpDNg57prOHapMbhv25RNf75lVRd6JDsni1AJJIDYoTY
%26oauth_version%3D1.0
 
接着将consumer_secret和oauth_token_secret连接起来,中间用&分割(这是准备密钥的方法,下面还会用到):
MCD8BKwGdgPHvAuvgvz4EQpqDAtx89grbuNMRd7Eh98&x6qpRnlEmW9JbQn4PQVVeVG8ZLPEx6A0TOebgwcuA
生成的OAuth签名如下:
PUw/dHA4fnlJYM6RhXk5IU/0fCc=
然后向给定的url发送请求,请求头部一定要包含request token,request头部如下:
OAuth oauth_nonce="9zWH6qe0qG7Lc1telCn7FhUbLyVdjEaL3MO5uHxn8", oauth_signature_method="HMAC-SHA1", oauth_timestamp="1272323047", oauth_consumer_key="GDdmIQH6jhtmLUypg82g", oauth_token="8ldIZyxQeVrFZXFOZH5tAwj6vzJYuLQpl0WUEYtWc", oauth_verifier="pDNg57prOHapMbhv25RNf75lVRd6JDsni1AJJIDYoTY", oauth_signature="PUw%2FdHA4fnlJYM6RhXk5IU%2F0fCc%3D", oauth_version="1.0"
新浪微博开放平台会返回应用需要的信息,包括用户名,oauth_token/oaut_token_secret(当然这里就是access token了)。 response内容如下:
oauth_token=819797-Jxq8aYUDRmykzVKrgoLhXSq67TEa5ruc4GJC2rWimw&oauth_token_secret=J6zix3FfA9LofH0awS24M3HcBYXO5nI1iYe8EfBA&user_id=819797&screen_name=openapi
现在就可以使用access token来发布信息了。

Viewing all articles
Browse latest Browse all 16

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>