php http 请求数据

WBOY
Release: 2016-06-20 12:54:11
Original
1219 people have browsed it

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


Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template