forked from ccbikai/weibotools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tenc.py
41 lines (29 loc) · 1.49 KB
/
tenc.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from qqweibo import APIClient
class Tenc(object):
def __init__(self, app_key, app_secret, callback_url, access_token, openid):
self.api = APIClient(app_key, app_secret, redirect_uri=callback_url)
self.api.set_access_token(access_token, openid, "1521094035")
def getTimeline(self, count):
""" 获取用户当前发布的微博 """
timeline = self.api.get.statuses__broadcast_timeline(format="json",pageflag=0,pagetime=0,lastid=0,contenttype=0,reqnum=count, type=1)
return timeline.data
def getFavorites(self, count):
""" 获取用户当前收藏的微博 """
favs = self.api.get.fav__list_t(format="json",pageflag=0,pagetime=0,lastid=0,reqnum=count)
return favs.data
def getUid(self):
""" 获取当前用户UID """
uid = self.api.get.user__info(format="json")
return uid.data.name
def getUser(self, name):
""" 获取用户信息 """
user = self.api.get.user__other_info(format="json",name=name)
return user.data
def postPic(self, content, pic_url, longitude=None, latitude=None):
if longitude==None or latitude==None:
t = self.api.post.t__add_pic(content= content, pic=pic_url)
else:
t = self.api.post.t__add_pic(content= content, longitude=longitude, latitude=latitude, pic=pic_url)
return t.id