您好,欢迎访问一九零五行业门户网

Call to a member function valid() on boolean这是出了什么错误?

我把一段代码从thinkphp 3.1 移植到 thinkphp 3.2 ,然后调整的时候出现了这么一个错误,找了好多都没找到。
public function init() { $config = m ( wxconfig )->where ( array ( id => 1 ) )->find (); $options = array ( 'token' => $config [token], // 填写你设定的key 'encodingaeskey' => $config [encodingaeskey], // 填写加密用的encodingaeskey 'appid' => $config [appid], // 填写高级调用功能的app id 'appsecret' => $config [appsecret], // 填写高级调用功能的密钥 ); $weobj = a('api/wechat ( $options )'); return $weobj; } public function index() { $weobj = $this->init(); $weobj -> valid ();

下面是api/wechat中的那个 valid方法:
/** * for weixin server validation * @param bool $return 是否返回 */ public function valid($return=false) { $encryptstr=; if ($_server['request_method'] == post) { $poststr = file_get_contents(php://input); $array = (array)simplexml_load_string($poststr, 'simplexmlelement', libxml_nocdata); $this->encrypt_type = isset($_get[encrypt_type]) ? $_get[encrypt_type]: ''; if ($this->encrypt_type == 'aes') { //aes加密 $this->log($poststr); $encryptstr = $array['encrypt']; $pc = new prpcrypt($this->encodingaeskey); $array = $pc->decrypt($encryptstr,$this->appid); if (!isset($array[0]) || ($array[0] != 0)) { if (!$return) { die('decrypt error!'); } else { return false; } } $this->postxml = $array[1]; if (!$this->appid) $this->appid = $array[2];//为了没有appid的订阅号。 } else { $this->postxml = $poststr; } } elseif (isset($_get[echostr])) { $echostr = $_get[echostr]; if ($return) { if ($this->checksignature()) return $echostr; else return false; } else { if ($this->checksignature()) die($echostr); else die('no access'); } } if (!$this->checksignature($encryptstr)) { if ($return) return false; else die('no access'); } return true; }

这是什么问题tat
回复内容: 我把一段代码从thinkphp 3.1 移植到 thinkphp 3.2 ,然后调整的时候出现了这么一个错误,找了好多都没找到。
public function init() { $config = m ( wxconfig )->where ( array ( id => 1 ) )->find (); $options = array ( 'token' => $config [token], // 填写你设定的key 'encodingaeskey' => $config [encodingaeskey], // 填写加密用的encodingaeskey 'appid' => $config [appid], // 填写高级调用功能的app id 'appsecret' => $config [appsecret], // 填写高级调用功能的密钥 ); $weobj = a('api/wechat ( $options )'); return $weobj; } public function index() { $weobj = $this->init(); $weobj -> valid ();

下面是api/wechat中的那个 valid方法:
/** * for weixin server validation * @param bool $return 是否返回 */ public function valid($return=false) { $encryptstr=; if ($_server['request_method'] == post) { $poststr = file_get_contents(php://input); $array = (array)simplexml_load_string($poststr, 'simplexmlelement', libxml_nocdata); $this->encrypt_type = isset($_get[encrypt_type]) ? $_get[encrypt_type]: ''; if ($this->encrypt_type == 'aes') { //aes加密 $this->log($poststr); $encryptstr = $array['encrypt']; $pc = new prpcrypt($this->encodingaeskey); $array = $pc->decrypt($encryptstr,$this->appid); if (!isset($array[0]) || ($array[0] != 0)) { if (!$return) { die('decrypt error!'); } else { return false; } } $this->postxml = $array[1]; if (!$this->appid) $this->appid = $array[2];//为了没有appid的订阅号。 } else { $this->postxml = $poststr; } } elseif (isset($_get[echostr])) { $echostr = $_get[echostr]; if ($return) { if ($this->checksignature()) return $echostr; else return false; } else { if ($this->checksignature()) die($echostr); else die('no access'); } } if (!$this->checksignature($encryptstr)) { if ($return) return false; else die('no access'); } return true; }

这是什么问题tat
$weobj = a('api/wechat ( $options )');
thinkphp a 函数不是这样调用吧
意思是说现在版本的tp的init方法在你这里的代码中没有返回对象,而是返回了布尔值,很可能是false;
跟踪一下3.2版本的a方法:
其它类似信息

推荐信息