post
function https_request($url, $data = null)
{
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE);
if (! empty($data)) {
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
}
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($curl);
curl_close($curl);
return $output;
}
$url="https://api.weixin.qq.com/cgi-bin/material/add_material?access_token=".$acc.'&type=thumb';
$real_path="{$_SERVER['DOCUMENT_ROOT']}".$file_info['filename'];
//$real_path=str_replace("/", "\\", $real_path);
$data= array("media"=>"@".$real_path,'form-data'=>$file_info);
$row=$this->https_request($url,$data);
return json_decode($row)->media_id;
get
$APPID = $GLOBALS['doyoConfig']['weixin']['appid'];
$APPSECRET = $GLOBALS['doyoConfig']['weixin']['appsecret'];
$url = 'https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid='.$APPID.'&secret='.$APPSECRET;
$rl = json_decode(file_get_contents($url));