希望高手指点一二,·······我用的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方法代替。控制器代码如下
<?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 关注
- 2681 浏览
相关问题推荐
添加回答
举报
0/150
提交
取消
