关注一个用户。

成功则返回关注人的资料，目前最多关注2000人，失败则返回一条字符串的说明。如果已经关注了此人，则返回http 403的状态。关注不存在的ID将返回400。
<br />对应API：{@link http://open.weibo.com/wiki/2/friendships/create friendships/create}

@access public
@param int $uid 要关注的用户UID
@return array
773568
function follow_by_id( $uid )
	{
		$params = array();
		$this->id_format($uid);
		$params['uid'] = $uid;
		return $this->oauth->post( 'friendships/create', $params );
	}
1272338
public function actionIndex($id)
    {
        // TODO 群发事件推送群发处理
        // TODO 模板消息事件推送处理
        // TODO 用户上报地理位置事件推送处理
        // TODO 自定义菜单事件推送处理
        // TODO 微信小店订单付款通知处理
        // TODO 微信卡卷(卡券通过审核、卡券被用户领取、卡券被用户删除)通知处理
        // TODO 智能设备接口
        // TODO 多客服转发处理
        $request = Yii::$app->request;
        $wechat = $this->findWechat($id);
        if (!$wechat->getSdk()->checkSignature()) {
            return 'Sign check fail!';
        }
        switch ($request->getMethod()) {
            case 'GET':
                if ($wechat->status == Wechat::STATUS_INACTIVE) { // 激活公众号
                    $wechat->updateAttributes(['status' => Wechat::STATUS_ACTIVE]);
                }
                return $request->get('echostr');
            case 'POST':
                $this->setWechat($wechat);
                $this->message = $this->parseRequest();
                $result = null;
                if($this->beforeProcess()) {
                    $result = $this->resolveProcess(); // 处理请求
                    $this->afterProcess($result);
                }
                return is_array($result) ? $this->createResponse($result) : $result;
            default:
                throw new NotFoundHttpException('The requested page does not exist.');
        }
    }
1143166
public static function createGUID() {
        if (function_exists('com_create_guid')) {
            return substr(com_create_guid(),1,36);
        }
        else {
            mt_srand((double) microtime() * 10000);
            $charid = strtoupper(md5(uniqid(rand(), true)));
            $hyphen = chr(45);
            $uuid = substr($charid, 0, 8) . $hyphen .
                    substr($charid, 8, 4) . $hyphen .
                    substr($charid, 12, 4) . $hyphen .
                    substr($charid, 16, 4) . $hyphen .
                    substr($charid, 20, 12);

            return $uuid;
        }
    }
413960
function friends_chain_followers( $uid, $page = 1, $count = 50 )
	{
		$params = array();
		$this->id_format($uid);
		$params['uid'] = $uid;
		$params['count'] = $count;
		$params['page'] = $page;
		return $this->oauth->get( 'friendships/friends_chain/followers',  $params );
	}
1220677
public function getInfo($id)
    {
        // 验证有效性
        if ($this->isValid($id) === false) {
            return false;
        }
        $code = $this->_checkIdArgument($id);
        $addressInfo = $this->_getAddressInfo($code['addressCode'], $code['birthdayCode']);

        return [
            'addressCode'   => $code['addressCode'],
            'abandoned'     => isset($this->_addressCodeList[$code['addressCode']]) ? 0 : 1,
            'address'       => is_array($addressInfo) ? implode($addressInfo) : '',
            'addressTree'   => array_values($addressInfo),
            'birthdayCode'  => date('Y-m-d', strtotime($code['birthdayCode'])),
            'constellation' => $this->_getConstellation($code['birthdayCode']),
            'chineseZodiac' => $this->_getChineseZodiac($code['birthdayCode']),
            'sex'           => ($code['order'] % 2 === 0 ? 0 : 1),
            'length'        => $code['type'],
            'checkBit'      => $code['checkBit'],
        ];
    }
761874
public function refreshUser($uid) {
		$user = WechatUser::findOne($uid);
		if(!$user) {
			throw new ErrorException('数据查询失败');
		}

		$data = $this->getData('/cgi-bin/user/info', [
			'access_token' => $this->getAccessToken(),
			'openid' => $user->openid,
			'lang' => \Yii::$app->language,
		]);

		$result = $this->errcode == 0;
		if($result) {
			$user->subscribe = $data['subscribe'];
			if($user->subscribe == 1) {
				$user->subscribed_at = $data['subscribe_time'];
				$user->name = $data['nickname'];
				$user->sex = $data['sex'];
				$user->country = $data['country'];
				$user->city = $data['city'];
				$user->province = $data['province'];
				$user->language = $data['language'];
				$user->headimgurl = $data['headimgurl'];
				$user->remark = $data['remark'];
				$user->groupid = $data['groupid'];
			}
			if(isset($data['unionid'])) {
				$user->unionid = $data['unionid'];
			}
			$user->save();
		}

		return $result;
	}
889427
function account_education( $uid = NULL )
	{
		$params = array();
		if ($uid) {
			$this->id_format($uid);
			$params['uid'] = $uid;
		}
		return $this->oauth->get( 'account/profile/education', $params );
	}
588783
public function updateGroupUsers($uids, $gid) {
		if(is_array($uids)) {
			$uids = implode(',', $uids);
		}

		$query = WechatUser::find()->where("id in ($uids) and groupid <> $gid");
		$users = $query->all();
		$openids = ArrayHelper::getColumn($users, 'openid');

		if(!$openids) {
			return true;
		}

		$data = $this->getData('/cgi-bin/groups/members/batchupdate', [
			'access_token' => $this->getAccessToken(),
		], Json::encode([
			'openid_list' => $openids,
			'to_groupid' => $gid,
		]));

		$result = $this->errcode == 0;
		if($result) {
			foreach($users as $user) {
				if($user->group->updateCounters(['count' => -1])) {
					$user->groupid = $gid;
					if($user->save()) {
						$user->refresh();
						$user->group->updateCounters(['count' => 1]);
					}
				}
			}
		}

		return $result;
	}
179689
public function getGroupAuthList($gid, $type = 1)
    {
        // 转换表名
        $auth_group = $this->config['auth_group'];
        $auth_rule = $this->config['auth_rule'];
        // 执行查询
        $rules = Db::name($auth_group)->where(['status'=>1, 'id'=>$gid])->value('rules');
        // 格式化access表id
        $ids = explode(',', trim($rules, ','));
        $ids = array_unique($ids);
        $map = array(
            'id' => ['in', $ids],
            'type' => $type,
            'status' => 1,
        );
        //读取用户组所有权限规则
        $rules = Db::name($auth_rule)->where($map)->column('title,name,condition');

        return $rules;
    }
760310
public function getUserList($next_openid = '')
    {
        if (!$this->access_token && !$this->getAccessToken()) {
            return false;
        }
        $result = Tools::httpGet(self::API_URL_PREFIX . self::USER_GET_URL . "access_token={$this->access_token}&next_openid={$next_openid}");
        if ($result) {
            $json = json_decode($result, true);
            if (empty($json) || !empty($json['errcode'])) {
                $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505';
                $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容！';
                return $this->checkRetry(__FUNCTION__, func_get_args());
            }
            return $json;
        }
        return false;
    }
1193149
public function getUidAppid($uid = '', $type = "all") {
        $key  = md5($uid . md5($uid . 'thirdAuthorizeCallback') . "_wechat");
        $data = to_array(F($key, '[get]'));
        if ($data) {
            switch ($type) {
            case 'appid':
                return $data['authorizer_appid'];
                break;
            default:
                return $data;
                break;
            }
        } else {
            return false;
        }
    }
360650
public static function getGroupMemberRoles($uid, $gid)
	{
		$db = \App::get('db');
		$sql = "SELECT r.id, r.name, r.permissions FROM `#__xgroups_roles` as r, `#__xgroups_member_roles` as m WHERE r.id=m.roleid AND m.uidNumber=" . $db->quote($uid) . " AND r.gidNumber=" . $db->quote($gid);
		$db->setQuery($sql);

		return $db->loadAssocList();
	}
1087419
public function getRuleData($uid) {

        if (empty($this->ruleData) && !empty($uid)){

            $rule_data = $this->config['auth_cache'] ? Cache::get($this->getRuleKey($uid)) : [];


            if (empty($rule_data) || !is_array($rule_data)){

                $join = '__AUTH_RULE__ b';

                $where = [];
                $groups = $this->getRoleUser($uid);
                $where['a.role_id'] = ['in',$groups];

                $where['b.status'] = 1;

                $rule_data = Db::name('auth_access')->alias("a")
                    ->field('b.name,b.condition')
                    ->join($join,'a.rule_name = b.name')
                    ->where($where)
                    ->select();

                if (empty($rule_data)) return false;

                if ($this->config['auth_cache'])
                    Cache::set($this->getRuleKey($uid),$rule_data);

            }

            $this->ruleData = $rule_data;

        }

        return $this->ruleData;
    }
229648
protected function createGhost($uid)
    {
        /** @var \Tx_Oelib_Model $model */
        $model = GeneralUtility::makeInstance($this->modelClassName);
        $model->setUid($uid);
        $model->setLoadCallback([$this, 'load']);
        $this->map->add($model);

        return $model;
    }
192918
public function bindUid($fd, $uid, $isKick = true)
    {
        if (!is_string($uid) && !is_int($uid)) {
            throw new \Exception('uid必须为string或者int');
        }
        //这里转换成string型的uid，不然ds/Set有bug
        $uid = (string) $uid;
        if ($isKick) {
            $this->kickUid($uid, false);
        }
        $this->uid_fd_table->set($uid, ['fd' => $fd]);
        $this->fd_uid_table->set($fd, ['uid' => $uid]);
        if ($this->isCluster()) {
            ProcessManager::getInstance()->getRpcCall(ClusterProcess::class, true)->my_addUid($uid);
        } else {
            get_instance()->pub('$SYS/uidcount', $this->uid_fd_table->count());
        }
    }
697053
protected function checkRule($name , $uid){
        
        $rule = $this->getRule($name);
        
        if (!$rule){
            $this->errorCode = '100001';
            $this->errorMsg = '验证规则不存在';
            
            return false;
        }else{
            $ruleIds = $this->getRuleIds($uid);
            $ruleId = $rule['id'];
            
            $check = in_array($ruleId , $ruleIds);
            if ($check){
                
                return true;
            }else{

                $this->errorCode = '100002';
                $this->errorMsg = '验证规则无权限';
                return false;
            }
            
        }
    }
1270014
private function getPageByUid($uid)
    {
        if (null === $page = $this->getApplication()->getEntityManager()->find('BackBee\NestedNode\Page', $uid)) {
            throw new NotFoundHttpException("Unable to find page with uid `$uid`");
        }

        return $page;
    }