?? ????? function add_material($obj) {
?? ???????? $file_info = array(
?? ??????? ??? ??? ??? ?'filename'???? => '/Public/Public/download.png', //圖片片相對(duì)于網(wǎng)站根目錄的路徑
?? ??? ??? ??? ???????? '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']);
?? ??? ??? ?}
?????????? ?
?? ??? ?}