新浪微博 使用OAuth2.0调用API

时间:2023-03-09 14:30:34
新浪微博 使用OAuth2.0调用API
# -*- coding: cp936 -*-
#python 2.7.10
#xiaodeng
#新浪微博 使用OAuth2.0调用API
#微博开放接口的调用,都需要获取用户的身份认证。目前微博开放平台用户认证鉴权主要采用OAuth2.0。 #使用OAuth2.0调用API接口有2个方式:
1、直接使用参数,传递参数名为access_token
URL='https://api.weibo.com/2/statuses/public_timeline.json?access_token=abcd' 2、在header里传递,形式为在header里添加Authorization:OAuth2空格abcd
#其他接口,参数正常传递即可。
#req.add_header('Authorization', 'OAuth2 %s' % authorization)
#注意在OAuth2后面是有一个空格的 注:所有的微博开放平台接口都部署在weibo.com域下