Retrieve username, password parameters passed through curl

前端 未结 4 1322
轮回少年
轮回少年 2021-01-07 12:34

I am trying to send username and password parameters to a url using curl, and I want to retrieve them. I send the parameters to a page, like the following:

&         


        
4条回答
  •  借酒劲吻你
    2021-01-07 13:13

    By default, cURL issues an HTTP GET request. In this case, you'd have to append the parameters to the URL you're calling:

    $curl = curl_init('http://localhost/sample.php?foo=bar&baz=zoid');
    

    In sample.php, $_GET['bar'] and $_GET['baz'] would be available respectively. If it's a POST request, you want to issue, you'll need to set the parameters via curl_setopt:

    $curl = curl_init('http://localhost/sample.php');
    curl_setopt($curl, CURLOPT_POSTFIELDS, 'foo=bar&baz=zoid');
    

提交回复
热议问题