本文整理汇总了Python中weibo.APIClient.users__show方法的典型用法代码示例。如果您正苦于以下问题:Python APIClient.users__show方法的具体用法?Python APIClient.users__show怎么用?Python APIClient.users__show使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类weibo.APIClient
的用法示例。
在下文中一共展示了APIClient.users__show方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: WeiboSdk
# 需要导入模块: from weibo import APIClient [as 别名]
# 或者: from weibo.APIClient import users__show [as 别名]
class WeiboSdk():
def __init__(self, appKey = WHERE_PLAY_KEY, appSecret = WHERE_PLAY_SECRET, redirectUri = WHERE_PLAY_CALLBACK):
self._client = APIClient(app_key=appKey, app_secret=appSecret, redirect_uri=redirectUri)
def users_show(self, token, uid):
self._client.set_access_token(token, 0.0)
data = self._client.users__show(uid=uid, source=self._client.client_id,access_token=token)
return data
def statuses_user_timeline(self,token,uid,feature,page,count):
self._client.set_access_token(token, 0.0)
data = self._client.statuses__user_timeline(uid=uid, source=self._client.client_id,access_token=token,feature=feature,trim_user=1,page=page,count=count)
return data
def friendships_friends_bilateral(self,token, uid, page, count):
self._client.set_access_token(token, 0.0)
data = self._client.friendships__friends__bilateral(uid=uid, source=self._client.client_id,access_token=token,page=page,count=count)
return data
def tags_tags_batch(self,token, uids):
self._client.set_access_token(token, 0.0)
data = self._client.tags__tags_batch(uids=','.join(map(str,uids)), source=self._client.client_id, access_token=token)
return data
#----------------------------------------------
def statuses_user_timeline_all(self,token,uid,feature=0):
'''
feature false int 过滤类型ID,0:全部、1:原创、2:图片、3:视频、4:音乐,默认为0。
'''
ret = []
page = 1
while True:
data = self.statuses_user_timeline(token,uid,feature,page,100)
ret += [status['text'] for status in data['statuses']]
if len(data['statuses']) == 0:
break
page += 1
return ret
def getAllBiFriendsId(self, token, uid, minStatusNumber= None,minFollowerNumber = None):
ret = []
page = 1
while True:
data = self.friendships_friends_bilateral(token,uid,page,100)
if minStatusNumber:
data['users'] = filter(lambda a:a['statuses_count'] > minStatusNumber, data['users'])
if minFollowerNumber:
data['users'] = filter(lambda a:a['followers_count'] > minFollowerNumber, data['users'])
ret += [user['id'] for user in data['users']]
if len(data['users']) == 0:
break
page += 1
return ret
示例2: get
# 需要导入模块: from weibo import APIClient [as 别名]
# 或者: from weibo.APIClient import users__show [as 别名]
def get(self):
s_pin = self.request.get('code')
if s_pin:
sina = APIClient(app_key=APP_KEY, app_secret=APP_SECRET, redirect_uri=S_CALLBACK)
r = sina.request_access_token(s_pin)
sina.set_access_token(r.access_token,r.expires_in)
twitter = tweepy.OAuthHandler(CONSUMER_KEY,CONSUMER_SECRET)
twitter_auth_url = twitter.get_authorization_url()
self.response.out.write(html_src % (twitter_auth_url,sina.users__show(uid=r.uid).screen_name,twitter.request_token.key,twitter.request_token.secret,r.access_token,r.expires_in))
else:
self.response.out.write("""<p>Error!!!<a href="/">Home</a></p>""")
示例3: get_code
# 需要导入模块: from weibo import APIClient [as 别名]
# 或者: from weibo.APIClient import users__show [as 别名]
def get_code(ACCOUNT,PASSWORD):
#get url
client = APIClient(app_key = APP_KEY,app_secret = APP_SECRET,redirect_uri=CALLBACK_URL)
url = client.get_authorize_url()
#get code
conn = httplib.HTTPSConnection('api.weibo.com')
postdata = urllib.urlencode ({'client_id':APP_KEY,'response_type':'code','redirect_uri':CALLBACK_URL,'action':'submit','userId':ACCOUNT,'passwd':PASSWORD,'isLoginSina':0,'from':'','regCallback':'','state':'','ticket':'','withOfficalFlag':0})
conn.request('POST','/oauth2/authorize',postdata,{'Referer':url,'Content-Type': 'application/x-www-form-urlencoded'})
res = conn.getresponse()
location = res.getheader('location')
code = location.split('=')[1]
conn.close()
#get client
r = client.request_access_token(code)
access_token = r.access_token
expires_in = r.expires_in
client.set_access_token(access_token, expires_in)
all_tmp = client.users__show(uid = client.account__get_uid()['uid'])
rz7.PIC_URL = all_tmp['profile_image_url']
rz7.NAME = all_tmp['screen_name']
all = {}
#a count
flag = 0
data = []
all = client.statuses__home_timeline(count = 200)
d = dict(all)
#fobj = open("api_data","w")
tar = ''
for i in range(len(d['statuses'])):
if 'bmiddle_pic' in d['statuses'][i]:
tmp = {}
tmp['name'] = d['statuses'][i]['user']['screen_name']
tmp['text'] = d['statuses'][i]['text']
tmp['picture'] = d['statuses'][i]['bmiddle_pic']
tmp['face'] = d['statuses'][i]['user']['profile_image_url']
fn = tar + (str)(flag) + '.jpg'
urlretrieve(d['statuses'][i]['bmiddle_pic'],fn)
flag = flag + 1
data.append(tmp)
return data,flag
示例4: callback
# 需要导入模块: from weibo import APIClient [as 别名]
# 或者: from weibo.APIClient import users__show [as 别名]
def callback(request):
"""
用户授权后的回调
"""
code = request.GET.get(u'code')
client = APIClient(app_key=APP_KEY,app_secret=APP_SECRET,redirect_uri=CALLBACK_URL)
res = client.request_access_token(code)
access_token = res['access_token']
expires_in = res['expires_in']
request.session['access_token'] = access_token
request.session['expires_in'] = expires_in
client.set_access_token(access_token,expires_in)
uid = client.get.account__get_uid()['uid']
username = str(uid)+'@weibo'
email = str(uid) + '@weibo.com'
# 判断用户是否已经注册过
try:
user = User.objects.get(username=username)
except User.DoesNotExist:
# 注册一个微博用户
new_user = User.objects.create_user(username=username,email=email,password='*******')
new_user.is_active = True
try:
new_user.save()
except Exception,e:
return HttpResponse('连接新浪账号时出错:%s'%e)
# 获取用户的新浪信息
sina_profile = client.users__show(uid)
# 增加用户档案
new_prfile = UserProfile(user = new_user)
new_prfile.screen_name = sina_profile['screen_name'] # 截取前10个字符
new_prfile.city = '北京'
new_prfile.introduction = sina_profile['description']
try:
new_prfile.save()
except Exception,e:
return HttpResponse('注册账号时服务器出现错误:%s' %str(e))
示例5: SinaSdk
# 需要导入模块: from weibo import APIClient [as 别名]
# 或者: from weibo.APIClient import users__show [as 别名]
#.........这里部分代码省略.........
return ret
def searchStatus(self,token,keyword,pIndex,province, city):
self._client.set_access_token(token, 0.0)
ret = None
try:
year = strftime("%Y",localtime())
mon = strftime("%m",localtime())
day = strftime("%d",localtime())
hour = strftime("%H",localtime())
key = year + mon+day+hour
ret = self._client.get.search__statuses(q=keyword,page=pIndex,province=province, city=city, count=50, source=WHERE_PLAY_KEY)
self.redisOfflineOperator.updateCount(key, 1)
ret[self.RET_CODE] = self.SUCCESS_CODE
ret[self.ERR_MSG] = ''
return ret
except:
print '======== ret ====='
print ret
print traceback.format_exc()
ret = {}
ret[self.RET_CODE] = self.FAILD_CODE
ret[self.ERR_MSG] = 'the request sina is error'
return ret
def usersShow(self, token, uid):
self._client.set_access_token(token, 0.0)
year = strftime("%Y",localtime())
mon = strftime("%m",localtime())
day = strftime("%d",localtime())
hour = strftime("%H",localtime())
ret = self._client.users__show(uid=uid, source=self._client.client_id)
return ret
def collectStatus(self,token,userid,pagecount):
self._client.set_access_token(token, 0.0)
try:
year = strftime("%Y",localtime())
mon = strftime("%m",localtime())
day = strftime("%d",localtime())
hour = strftime("%H",localtime())
key = year + mon+day+hour
if(self.redisOfflineOperator.getCount(key)==self.MAX_COUNT):
ret = {}
ret[self.LIMITED_CODE]=self.RATE_LIMITED
ret[self.RET_CODE] = self.FAILD_CODE
ret[self.ERR_MSG] = 'the request sina is error'
return ret
elif(self.redisOfflineOperator.getCount(key)==None):
self.redisOfflineOperator.updateCount(key, 0)
ret = self._client.get.statuses__user_timeline(uid=userid,count=200,page=pagecount)
self.redisOfflineOperator.updateCount(key, 1)
except:
print traceback.format_exc()
self.redisOfflineOperator.updateCount(key, 1)
ret = {}
ret[self.RET_CODE] = self.FAILD_CODE
ret[self.ERR_MSG] = 'the request sina is error'
return ret
if(ret == None):
ret = {}
ret[self.RET_CODE] = self.EMPTY_CONTENT