php发送get post 请求

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));
HTTPROOT | 自学PHP | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 石头哥 |微信小程序 |木讯 |备案
Copyright © 1998 - 2016 HTTPROOT.COM. All Rights Reserved httproot.com 版权所有