HTTP Error 500 when using curl in PHP -
<?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 $value) { echo $value."<br>"; } ?>
this code displays synonyms of $word variable.when executing on xampp gives http error 500, worked fine before error emerged
the http status code 500 means in case, api key no longer valid or inactive key.
use proper authentication against api, before or request.
requesting api key described on here: https://words.bighugelabs.com/api.php
Comments
Post a Comment