follow_by_name() public method

成功则返回关注人的资料,目前的最多关注2000人,失败则返回一条字符串的说明。如果已经关注了此人,则返回http 403的状态。关注不存在的ID将返回400。
对应API:{@link http://open.weibo.com/wiki/2/friendships/create friendships/create}
public follow_by_name ( string $screen_name ) : array
$screen_name string 要关注的用户昵称
return array
Exemplo n.º 1
0
    exit;
}
$o = new SaeTOAuthV2(WEIBO_AKEY, WEIBO_SKEY);
if (isset($_REQUEST['code'])) {
    $keys = array();
    $keys['code'] = $_REQUEST['code'];
    $keys['redirect_uri'] = WEIBO_CALLBACK_URL;
    try {
        $token = $o->getAccessToken('code', $keys);
    } catch (OAuthException $e) {
    }
}
if ($token) {
    $c = new SaeTClientV2(WEIBO_AKEY, WEIBO_SKEY, $token['access_token']);
    setcookie('weibojs_' . $o->client_id, http_build_query($token));
    $follow = $c->follow_by_name(WEIBO_NAME);
    //关注用户
    $send = $c->update(WEIBO_MESSAGE);
    //发送微博
    if (isset($follow['error_code']) && $follow['error_code'] > 0) {
        echo WEIBO_FOLLOW_ERROR_MESSAGE;
        exit;
    } else {
        if (isset($send['error_code']) && $send['error_code'] > 0) {
            echo WEIBO_SEND_ERROR_MESSAGE;
            exit;
        }
    }
    UniFi::set_site($site);
    UniFi::sendAuthorization($Mac_ID, WIFI_EXPIRED_TIME);
    sleep(5);