def post(status,pic): f=open("../imgcache/"+pic,'r') requesturl='https://api.weibo.com/2/short_url/shorten.json?access_token='+r.get('access_token')+'&url_long=http://zh.moegirl.org/'+urllib.quote(status) req=urllib2.Request(requesturl) res=urllib2.urlopen(req).read() data=json.loads(res,object_hook=_decode_dict) shorturl=data['urls'][0]['url_short'] client.statuses.upload.post(status=status+shorturl,pic=f) f.close
def PrepareLogin(): access_token=r.get('access_token') expires_in=r.ttl('access_token') client.set_access_token(access_token, expires_in)