Reputation: 143
I am using curl in the terminal to access and request a JSON file. It should respond with a JSON file.
curl --basic --user email : password "http:/www.appannie.com/v1/accounts/acntnum/..."
What is its equivalent in PHP curl?
I have used:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERPWD, $email.".".$password);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
$response = curl_exec($ch);
$info = curl_getinfo($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
return $response;
But it fails.
My reference is this: http://support.appannie.com/categories/20082753-Analytics-API
Upvotes: 0
Views: 459
Reputation: 13535
I believe the USER PASSWORD needs to be separated by ':'
curl_setopt($ch, CURLOPT_USERPWD, $email.":".$password);
Upvotes: 1