/*
*新增永久媒体文件
*/
public function up_video_towx($video_path, $data, $description)
{
$url = "https://api.weixin.qq.com/cgi-bin/material/add_material?access_token=".$this->access_token."&type=video";
/*$file_info=array(
'filename'=>'/images/1.png', //国片相对于网站根目录的路径
'content-type'=>'image/png', //文件类型
'filelength'=>'11011' //图文大小
);*/
if($data['filename'] != "")
{
$curlPost['media'] = '@' . $video_path;
$curlPost['form-data'] = $data;
$title = urlencode($description['title']);
$introduction = urlencode($description['introduction']); //避免汉字乱码
$description_new['title'] = $title;
$description_new['introduction'] = $introduction;
$curlPost['description'] = urldecode(json_encode($description_new));
$res = json_decode($this->helper->httpPost($curlPost, $url), true);
if(isset($res['media_id']))
{
return $res;
}else
{
return "";
}
}else
{
return "";
}
*新增永久媒体文件
*/
public function up_video_towx($video_path, $data, $description)
{
$url = "https://api.weixin.qq.com/cgi-bin/material/add_material?access_token=".$this->access_token."&type=video";
/*$file_info=array(
'filename'=>'/images/1.png', //国片相对于网站根目录的路径
'content-type'=>'image/png', //文件类型
'filelength'=>'11011' //图文大小
);*/
if($data['filename'] != "")
{
$curlPost['media'] = '@' . $video_path;
$curlPost['form-data'] = $data;
$title = urlencode($description['title']);
$introduction = urlencode($description['introduction']); //避免汉字乱码
$description_new['title'] = $title;
$description_new['introduction'] = $introduction;
$curlPost['description'] = urldecode(json_encode($description_new));
$res = json_decode($this->helper->httpPost($curlPost, $url), true);
if(isset($res['media_id']))
{
return $res;
}else
{
return "";
}
}else
{
return "";
}
}
$updata['filename'] = $file_name;
$updata['content-type'] = $_FILES['video']['type'];
$updata['filelength'] = $size;
$real_file = ROOT_PATH . $file;
$description['title'] = $title;
$description['introduction'] = $digest;
$upres = $wxClassLib->up_video_towx($real_file, $updata, $description);