Home  >  Article  >  Backend Development  >  php http 请求数据

php http 请求数据

WBOY
WBOYOriginal
2016-06-20 12:54:111144browse

$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);


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn