issues
search
dodgepudding
/
wechat-php-sdk
微信公众平台php开发包, weixin developer SDK.
4.44k
stars
2.33k
forks
source link
修改“根据code获取成员信息",获取成功后,显示'$json['error']未定义'错误
#347
Open
spristar
opened
7 years ago
spristar
commented
7 years ago
[ 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; }
$this->errCode = $json['errcode']; $this->errMsg = $json['errmsg']; return false;
} return $json; } return false; }