I'm trying to connect to a API service using the following php:
$url = 'https://api.wlvpn.com/v2/customers&api-key=my-api-key'
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_PROXY, "http://127.0.0.1/");
$output = curl_exec($ch);
$curl_error = curl_error($ch);
curl_close($ch);
print_r($output);
print_r($curl_error);
when I run it I get the following error:
couldn't connect to host
However, when I run the following command from my command line in ubuntu:
jai@ubuntu:/opt/lampp$ curl -u api-key:my-api-key https://api.wlvpn.com/v2/customers
I get a response as expected
Can anyone help me what I am missing here
I think I am missing -u option but I dont have any idea how to put it on my php code
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…