//模拟get请求
$cur1='https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=appid&secret=secret';
$data1=file_get_contents($cur1);
//显示获得的数据并转化
$data1=json_decode($data1,1);
    //获取数据模拟post请求
    $urla = 'https://api.weixin.qq.com/cgi-bin/wxaapp/createwxaqrcode?access_token='.$data1['access_token']; 
    $post_data = array(
        "path" => "pages/index/index?userid=33",
        "width" => "430"
        );
    $post_data=json_encode($post_data);


    $ch = curl_init();
    $header = "Accept-Charset: utf-8";
    curl_setopt($ch, CURLOPT_URL, $urla);
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
    curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (compatible; MSIE 5.01; Windows NT 5.0)');
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
    curl_setopt($ch, CURLOPT_AUTOREFERER, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $tmpInfo = curl_exec($ch);
    //显示获得的数据
    $timeday=time();
    $config['upload_path'] = UPLOAD_PATH.date('Y',$timeday).'/'.date('m',$timeday).'/'.date('d',$timeday).'/';
    $upload_dir = $config['upload_path'];
    if (!is_dir($upload_dir)) {
        mkdir($upload_dir, 0755, true);
    }
    $filename=rand(0,10000).date("YmdHis").rand_str().nanoSecond().'.jpg';
    $filepath=$config['upload_path'].$filename;
    //把获取到的数据串存入文件中
    file_put_contents($filepath,$tmpInfo);
10-18 04:16