1首先测试有无公众号使用
class AutoreplyController extends Controller{
private $mp;
//初始化
public function _initialize(){
$mp = getCurrentMp();
if (empty($mp)) {
$this->error('无使用的公众号',U('mp/index'));
exit();
}else{
$this->mp = $mp;
}
}
2.写入addimage方法
public function addimage(){
if(IS_GET){
$this->display('replyimage');
}else{
$data = array();
$url = I('post.url'); //图片路径
$file = realpath('.' . $url); //相对路径转绝对路径
$access_token = getAccess_token();
include APP_PATH .'LaneWeChat/lanewechat.php';
$url = "https://api.weixin.qq.com/cgi-bin/material/add_material?access_token=$access_token&type=image";
$data['m