Calltoamemberfunctionvalid () onboolean what is the error?

Source: Internet
Author: User
Tags crypt
I transplanted a piece of code from thinkphp3.1 to thinkphp3.2, and then there was such an error during the adjustment, so I couldn't find many of them. {Code ...} the valid method in ApiWechat is as follows: {code ...} what is the problem? I transplanted a piece of code from thinkphp 3.1 to thinkphp 3.2. Then, when I adjusted the code, I found this error and found a lot of problems.

Public function init () {$ config = M ("Wxconfig")-> where (array ("id" => "1")-> find (); $ options = array ('Token' => $ config ["token"], // enter your set key 'enabledingaeskey' => $ config ["encodingaeskey"], // enter the encryption EncodingAESKey 'appid '=> $ config ["appid"], // enter the app id 'appsecret' => $ config ["appsecret"] of the Advanced Call function, // enter the key of the Advanced Call function ); $ weObj = A ('api/Wechat ($ options) '); return $ weObj;} public function index () {$ weObj = $ this-> init (); $ weObj-> valid ();

The valid method in Api/Wechat is as follows:

/*** For weixin server validation * @ param bool $ return whether to 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 encryption $ this-> log ($ postStr ); $ encryptStr = $ array ['enabled']; $ pc = new Prpcrypt ($ this-> encodingAesKey); $ array = $ pc-> decrypt ($ encryptStr, $ this-> appid); if (! Isset ($ array [0]) | ($ array [0]! = 0) {if (! $ Return) {die ('crypt error! ');} Else {return false; }}$ this-> postxml = $ array [1]; if (! $ This-> appid) $ this-> appid = $ array [2]; // for subscription numbers without 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 ;}

What's the problem? TAT

Reply content:

I transplanted a piece of code from thinkphp 3.1 to thinkphp 3.2, and then there was such an error during the adjustment, and I couldn't find it after finding a lot.

Public function init () {$ config = M ("Wxconfig")-> where (array ("id" => "1")-> find (); $ options = array ('Token' => $ config ["token"], // enter your set key 'enabledingaeskey' => $ config ["encodingaeskey"], // enter the encryption EncodingAESKey 'appid '=> $ config ["appid"], // enter the app id 'appsecret' => $ config ["appsecret"] of the Advanced Call function, // enter the key of the Advanced Call function ); $ weObj = A ('api/Wechat ($ options) '); return $ weObj;} public function index () {$ weObj = $ this-> init (); $ weObj-> valid ();

The valid method in Api/Wechat is as follows:

/*** For weixin server validation * @ param bool $ return whether to 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 encryption $ this-> log ($ postStr ); $ encryptStr = $ array ['enabled']; $ pc = new Prpcrypt ($ this-> encodingAesKey); $ array = $ pc-> decrypt ($ encryptStr, $ this-> appid); if (! Isset ($ array [0]) | ($ array [0]! = 0) {if (! $ Return) {die ('crypt error! ');} Else {return false; }}$ this-> postxml = $ array [1]; if (! $ This-> appid) $ this-> appid = $ array [2]; // for subscription numbers without 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 ;}

What's the problem? TAT

$ WeObj = A ('api/Wechat ($ options )');

Isn't Thinkphp A called like this?

This indicates that the current version of the TP init method does not return an object in your code, but returns a Boolean value, which may be false;

Follow up the method of version 3.2:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.