在PHP中使用curl时出现HTTP错误500
此代码显示$word变量的同义词。在xampp上执行时,出现http错误500,以前工作正常,但现在出现此错误。在本例中,http状态代码500表示API密钥不再有效或是非活动密钥 在请求之前或与请求一起对此API使用适当的身份验证 此处描述了请求API密钥:在PHP中使用curl时出现HTTP错误500,php,http,curl,asp.net-web-api,Php,Http,Curl,Asp.net Web Api,此代码显示$word变量的同义词。在xampp上执行时,出现http错误500,以前工作正常,但现在出现此错误。在本例中,http状态代码500表示API密钥不再有效或是非活动密钥 在请求之前或与请求一起对此API使用适当的身份验证 此处描述了请求API密钥: <?php ini_set('display_errors', 1); set_time_limit(0); $word = "product"; $ch = curl_init(); curl_setopt($ch, CURLO
<?php
ini_set('display_errors', 1);
set_time_limit(0);
$word = "product";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://words.bighugelabs.com/api/2/ad63536b2f8108efe8c07295746c5a09/$word/json");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);
$bigarray = array();
if ($info['http_code'] == 200) {
$result = json_decode($data, true);
$final = json_encode($result,JSON_PRETTY_PRINT);
file_put_contents("results.json", $final);
$bigarray = $result["noun"]["syn"];
}
else echo "Http Error: ".$info['http_code'];
foreach ($bigarray as $value) {
echo $value."<br>";
}
?>