Skip to content

Conversation

@spristar
Copy link

  • [ 1782] 1.public function getUserId($code,$agentid=0){
    if (!$agentid) $agentid=$this->agentid;
    if (!$this->access_token && !$this->checkAuth()) return false;
    $result = $this->http_get(self::API_URL_PREFIX.self::USER_GETINFO_URL.'access_token='.$this->access_token.'&code='.$code.'&agentid='.$agentid);
    if ($result)
    {
    $json = json_decode($result,true);
    //if (!$json || !empty($json['errcode']) || $json['errcode']!=0) {// change it to the below
    if (isset($json['errcode'])) {//主要修改这里,将上一行修改如左侧代码
    /*
    *无论怎样,微信服务器端都会返回信息,也即!$json 总是为真
    *但是,当用正确的code时,微信服务器回复的信息里并无$json['errcode']这一项
    *这样导致"或"判断时,会出现$json['errcode']未定义错误
    * 修改之后则不会了,会更加准确的判断服务器回复内容,便于后续处理
    */
    $this->errCode = $json['errcode'];
    $this->errMsg = $json['errmsg'];
    return false;
    }
    return $json;
    }
    return false;
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants