Skip to content

Instantly share code, notes, and snippets.

@cloverstd
Created December 19, 2012 12:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cloverstd/4336243 to your computer and use it in GitHub Desktop.
Save cloverstd/4336243 to your computer and use it in GitHub Desktop.
Weibo test by Python
#!/usr/bin/env python
# -*- coding:utf-8 -*-
import urllib, json
#access_token = "access_token=2.00ZKiKnBbdwdeB51f779176atx5VHB"
status = "测试测试测试"
def update_status(status):
push_data = {
"access_token": "**********************",
"status": status
}
url_push = "https://api.weibo.com/2/statuses/update.json"
push = urllib.urlopen(url_push, urllib.urlencode(push_data)).read().decode('utf-8')
weibo = json.loads(push)
print "%s 发表成功" % weibo['text'].encode('utf-8')
def get_status(n):
url = "https://api.weibo.com/2/statuses/friends_timeline.json?"
access_token = "access_token=2.00ZKiKnBbdwdeB51f779176atx5VHB"
count = "&count=" + str(n)
status = urllib.urlopen(url + access_token + count).read().decode('utf-8')
weibo = json.loads(status)
for l in weibo['statuses']:
print "@%s:" % l['user']['name']
print l['text']
print '-' * 10
#status = raw_input("> ")
#update_status(status)
get_status(1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment