I have been writing a RESTful API for my Laravel application. I can submit data using cURL in Terminal with the following line;
curl -i --user admin@admin.com:qwertyuiop -d "data=somedata" https://www.xxxxxxxxxxxxx.co.uk/app/api/v1/clients
but when i try and do the same in cURL using PHP it gives me a 403 forbidden error.
$url = "https://www.xxxxxxxxxx.co.uk/app/api/v1/clients";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_USERPWD, "admin@admin.com:qwertyuiop");
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "data=mydata");
$output = curl_exec($ch);
curl_close($ch);
print_r($output);
Any ideas what i'm missing from my PHP cURL script? Thanks