function add_material($obj) {
$file_info = array(
'filename' => '/Public/Public/download.png', //图片片相对于网站根目录的路径
'content-type' => 'image/png', //文件类型
'filelength' => '11011' //图文大小
);
$access_token = $this -> get_access_token();
$url = "https://api.weixin.qq.com/cgi-bin/material/add_material?access_token={$access_token}&type=image";
$real_path = "{$_SERVER['SERVER_NAME']}{$file_info['filename']}";
$data = array("media" => "@{$real_path}", 'form-data' => $file_info);
$result = $this->https_request($url,$data);
$result = json_decode($result, true);
if($result['media_id'])
{
return $this->replyText($obj,$result['media_id']);
}else {
return $this->replyText($obj,$result['errcode']);
}
}
同求以上问题答案,遇到了同样的问题。各位牛人快来回答!