Created
December 19, 2012 12:08
-
-
Save cloverstd/4336243 to your computer and use it in GitHub Desktop.
Weibo test by Python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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