我在终端中使用curl来访问和请求JSON文件。它应该使用JSON文件进行响应。
curl --basic --user email : password "http:/www.appannie.com/v1/accounts/acntnum/..."
它在PHP curl中的等价物是什么?
我使用过:
$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;
但它失败了。
我的参考是:http://support.appannie.com/categories/20082753-Analytics-API
我认为用户密码需要用':'分隔
curl_setopt($ch, CURLOPT_USERPWD, $email.":".$password);