I have the following request to an API:
$url = "{{correctURLishere}}";
$response = json_decode(file_get_contents($url), true);
$name = $response["title"];
}
The This should bring back the value from they key "title" in this json response. But instead, the error I get is
file_get_contents(url): failed to open stream: HTTP request failed! HTTP/1.1 402
I know the error is because I am only allowed 150 requests a day and have exceeded this amount but can someone help me to echo "No more requests allowed" instead of the error?
I have tried the following but it wont work:
if(json_decode(file_get_contents($url), true)) {
$response = json_decode(file_get_contents($url), true);
$name = $response["title"];
}
Could anyone tell me how to help with the error? Thanks