关于微信验证,老是不通过

浏览:3123 发布日期:2013/07/02 分类:求助交流 关键字: 微信公众
大家看看我这样写对不对

<?php
class WeixinAction extends CommonAction{
public function index(){
/* 加载微信SDK */
import('ORG.Util.ThinkWechat');
$weixin = new ThinkWechat(I('callback_token')); //这里的TOKEN是在公众平台开发者模式中配置的TOKEN

/* 获取请求信息 */
$data = $weixin->request();

/* 获取回复信息 */
// 这里的回复信息是通过判断请求内容自行定制的, 不在SDK范围内,请自行完成
list($content, $type) = $this->reply($data);

/* 响应当前请求 */
$weixin->response($content, $type);
}

private function reply($data){

if('event' == $data['MsgType'] && 'subscribe' == $data['Event']){
$reply = array('欢迎您关注麦当苗儿公众助手!', 'text');
return $reply;
}

//回复文本消息
//$reply = array($data['Content'], 'text');
//
//回复图文消息
$data = array(
array('ThinkPHP七周年', '1', 'http://www.thinkphp.cn/Uploads/ad/2013-05-09/518b19ed4bd74.jpg', 'http://www.thinkphp.cn/7year.html'),
array('ThinkPHP发布3.1.3版本', '2', 'http://www.thinkphp.cn__NEW__/img/header_logo.png', 'http://www.thinkphp.cn'),
);
$reply = array($data, 'news');

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