Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修改“根据code获取成员信息",获取成功后,显示'$json['error']未定义'错误 #347

Open
wants to merge 18 commits into
base: develop
Choose a base branch
from

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