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:
&
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');