function http_post_media($url,$path){
$ch = curl_init();
if(class_exists('\CURLFile')){//兼容php版本>=5.5
curl_setopt($ch,CURLOPT_SAFE_UPLOAD,true);
$data = array('media'=>new \CURLFile(realpath($path)));
}else{//兼容php版本<5.5
if(defined('CURLOPT_SAFE_UPLOAD')){
curl_setopt($ch,CURLOPT_SAFE_UPLOAD,false);
}
$data = array('media'=>'@'.realpath($path));
}
if(stripos($url,"https://") != false){
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,FALSE);
curl_seropt($ch,CURLOPT_SSL_VERIFYHOST,FALSE);
}
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_POST,true);
curl_setopt($ch,CURLOPT_POSTFIELDS,$data);
$sContent = curl_exec($ch);
$aStatus = curl_getinfo($ch);
curl_close($ch);
if(inval($sStatus['http_code']) == 200){
return json_decode($sContent,true);
}else{
return false;
}
}