微信类公有方法返回失败

浏览:380 发布日期:2015/08/03 分类:求助交流 关键字: 微信公众号
类代码和调用代码都在附件里,用的是论坛里分享的麦当苗的代码。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 次 )

最佳答案
评论( 相关
后面还有条评论,点击查看>>