php http 请求数据

$url = 'https://......'; //请求地址

    $ref_url = ''//来源页面

    $data = array(  //提交的数据

        "param" => "",

        "param" => ""

    );

    $ch = curl_init();

    curl_setopt($ch, CURLOPT_URL, $url);

    curl_setopt($ch, CURLOPT_USERAGENT, $agent);

    curl_setopt($ch, CURLOPT_REFERER, $ref_url);

    curl_setopt($ch, CURLOPT_POST, TRUE); //以POST方式提交

    curl_setopt($ch, CURLOPT_POSTFIELDS, $data);

    curl_setopt($ch, CURLOPT_TIMEOUT, 30); //超时时间

    $contents = curl_exec($ch); //执行并获取返回数据

    curl_close($ch);

    var_dump($contents);


你可能感兴趣的:(php http 请求数据)