我正在做
$info = file_get_contents('http://USERNAME:PASSWORD@api.appfigures.com/v2/sales?client_key=CLIENT_KEY');
$info
什么都不返回。但是,当我将 URL 放入浏览器时,会出现 JSON。我尝试使用 cURL 没有任何运气。
$data = array('client_key' => 'CLIENT_KEY');
$link = "http://api.appfigures.com/v2/sales";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $link);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, count($data));
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($ch, CURLOPT_USERPWD, "username:password");
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
$jsonData = curl_exec($ch);
curl_close($ch);
print_r($jsonData);
谢谢