【发布时间】:2015-03-28 20:58:40
【问题描述】:
<?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>";
}
?>
此代码显示 $word 变量的同义词。在 xampp 上执行时出现 http 错误 500,之前工作正常,但现在出现此错误
【问题讨论】:
标签: php http curl asp.net-web-api