public function user($openid = '') {
if ($openid) {
header ( "Content-type: text/html; charset=utf-8" );
$url = 'https://api.weixin.qq.com/cgi-bin/user/info';
$params = array ();
$params ['access_token'] = $this->getToken ();
$params ['openid'] = $openid;
$httpstr = http ( $url, $params );
$harr = json_decode ( $httpstr, true );
return $harr;
} else {
return false;
}
}
这个是类公共方法public function tests(){
/* 加载微信SDK */
import ( "ORG.Util.ThinkWechat" );
$weixin = new ThinkWechat ();
$info = $weixin->user($openid);
dump($info);
}
这个是调用的公共方法,返回值是40003,无效的openid(额,openid我就隐去了),但是如果直接:public function tests(){
header ( "Content-type: text/html; charset=utf-8" );
$url = 'https://api.weixin.qq.com/cgi-bin/user/info';
$params = array ();
$params ['access_token'] = $this->getToken ();
$params ['openid'] = $openid;
$httpstr = http ( $url, $params );
dump($httpstr);
}
就可以正常返回微信用户的对应信息,很郁闷!请知道的亲告诉下是什么原因?thinkphp版本是3.1.2。
wechat.rar
( 10.55 KB 下载:0 次 )
最佳答案
