使用别人的api,就得面临人家升级、变动的情况,跟着变很烦,所以就得借助自动化工具了~

–TEST–
# vim: filetype=php
Sina Weibo SDK Test
–SKIPIF–
–FILE–
<?php
require(‘../weibooauth.php’);
define(‘TEST_KEY’, ‘3850844033’);
define(‘TEST_KEY_SECRET’, ‘9cd35fea86acd3c666d0fbddc42c0ba0′);
# http://apps.weibo.com/flykobe/ to get token
define(‘TEST_USER_ID’, ‘2298045197’); # a38672@nepwk.com
define(‘TEST_USER_TOKEN’, ‘5ffa72ac5e0baffd604e487196ff41cd’);
$_SERVER[‘REMOTE_ADDR’] = ‘127.0.0.1’;
# be careful, token generated by different sdk is different
$weiboClient = new WeiboClient(TEST_KEY, TEST_KEY_SECRET, TEST_USER_TOKEN);
# test get self info
$ret = $weiboClient->verify_credentials();
var_dump($ret[‘id’]);
# test send text weibo
$text = ‘Auto test by PHPT. ‘.rand();
$ret = $weiboClient->update($text);
var_dump($ret[‘id’]);
# test send pic weibo
$text = ‘Auto test by PHPT. ‘.rand();
$pic_path = ‘http://tp2.sinaimg.cn/1257818405/180/5607577090/0′; # make sure this pic can be visit by sina
$ret = $weiboClient->upload($text, $pic_path);
var_dump($ret[‘id’]);
# test un-follow
$friend_id = ‘1442255022’;
$ret = $weiboClient->unfollow($friend_id);
var_dump($ret[‘id’]);
# test follow
$friend_id = ‘1442255022’;
$ret = $weiboClient->follow($friend_id);
var_dump($ret[‘id’]);
# test friends_ids
$ret = $weiboClient->friends_ids(-1, 10);
var_dump($ret[‘ids’][0]);
?>
–EXPECTF–
float(%d)
float(%s)
float(%s)
int(1442255022)
int(1442255022)
int(%d)

Leave a Reply