希望高手指點一二,·······我用的tp3.2.3的,誰能告訴我為啥不好使啊
<?php
//控制器中的代碼
namespace?Home\Controller;
use?Think\Controller;
use?Home\Model\IndexModel;???//這里試了好幾種情況都不行
class?IndexController?extends?Controller?{
????public?function?reponseMsg()(){
????????..........
????????if?(strtolower($postObj->MsgType=='text'?&&?trim($postObj->Content=='tuwen2'))){
????????????//實例化
????????????$index?=?new?IndexModel();???//這里也是
????????????$index->responseNews($postObj);
????}
}
//模型中的代碼
namespace?Home\Model;
//use?Think\Model;
class?IndexModel?extends?\Think\Model{
????public?function?responseNews($postObj){
????????.....與之前的視頻代碼相同,可以出現圖文消息
????}
????/*?public?function?responseText($postObj,$content){
????????//回復單文本
?????????
????}?*/
}
8 回答

震海聽風
TA貢獻4條經驗 獲得超4個贊
還有兩點要注意:1、要建立mysql數據庫,隨便建一個 ? ? ? 2、Controller控制器代碼中,new方法用D方法代替??刂破鞔a如下
<?php //控制器中的代碼 namespace?Home\Controller; use?Think\Controller; use?Home\Model\IndexModel;???//這里試了好幾種情況都不行 class?IndexController?extends?Controller?{ ????public?function?reponseMsg()(){ ????????.......... ????????if?(strtolower($postObj->MsgType=='text'?&&?trim($postObj->Content=='tuwen2'))){ ????????????//實例化 ????????????$index?=?D('Index');?//$index?=?new?IndexModel();???//這里也是 ????????????$index->responseNews($postObj); ????} }

震海聽風
TA貢獻4條經驗 獲得超4個贊
兄弟,你上面的問題找出來了嗎。經過不懈的困惑,我終于得到答案了。直接上代碼!
//模型中的代碼 namespace?Home\Model; //use?Think\Model; class?IndexModel?extends?\Think\Model{ ???//追加以下這一段,就行了,很神奇啊!也能寫進數據庫 ????Protected?$autoCheckFields?=?false; ???public?function?__construct()?{ ????????????parent::__construct(); ????????????$this->$autoCheckFields; ????????} ???? ???? ????public?function?responseNews($postObj){ ????????.....與之前的視頻代碼相同,可以出現圖文消息 ????} ????/*?public?function?responseText($postObj,$content){ ????????//回復單文本 ?????????? ????}?*/ }
- 8 回答
- 0 關注
- 2630 瀏覽
相關問題推薦
添加回答
舉報
0/150
提交
取消