//回复图文
public function addNews(){
$mp=$this->mp;
$keyword=I('post.keyword');
$title=I('post.title');
$description=I('post.content');
$url=I('post.url');
//相对路径->绝对路径
$file=realpath('.'.$url);
$link=I('post.content_source_url');
$accessToken=getAccess_token();
include APP_PATH . 'LaneWeChat/lanewechat.php';
//上传永久图片api
$api="https://api.weixin.qq.com/cgi-bin/material/add_material?access_token=$accessToken&type=image";
$data['media']='@' . $file;
$ret=Curl::callWebServer($api,$data,'post',true,false);
if (isset($ret['url'])) {
$mp=$this->mp;
$arr['title']=$title;
$arr['url']=$link;
$arr['picurl']=$ret['url'];
$arr['description']=$description;
$ret=M('mp_reply_news')->add($arr);
if($ret){
$data['mpid']=$mp['id'];
$data['reply_id']=$ret;
$data['type']='news';
$data['keyword']=$keyword;
$rule=M('mp_rule');
$ret=$rule->add($data);
}
if ($ret) {
$this->ajaxReturn(array('status'=>0,'msg'=>"添加成功!"));
} else {
$this->ajaxReturn(array('msg'=>$ret));
}
}else{
$ret['fail']='本地上传失败';
$this->ajaxReturn(array('status'=>1,'msg'=>$ret));
exit;
}
}
关于微信开发的自动回复之图文消息
最新推荐文章于 2023-06-15 10:37:23 发布