So im basically trying to call an API that is supposed to ping a given IP address, but everything ive been trying hasn't been working, they used to work in the past because these are just snippets i gathered from an old project that used to work just fine, now they dont work, ive checked to see if it logged any PHP errors, but there was nothing in the logs.
Here are my sample codes:
cURL:
<?php
if (Isset($_POST['submit'])){
$host = $_POST['host'];
$url = "http://someapi.com/ping/?host=".$host;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec($ch);
curl_close($ch);
echo $data;
}
?>
<input type="text" name="host" placeholder="IP" />
<input type="submit" name="submit" value="Geo Locate" />
<br>
<center>
<?php echo $data; ?>
</center>
</form>
@File_Get_Contents
<form action="" method="POST">
<?php
If(Isset($_POST['submit'])){
$host = $_POST['host'];
$api = @File_Get_Contents("http://someapi.com/ping/?host=" .$host. "");
echo $api;
}
?>
<input type="text" name="host" placeholder="IP" />
<input type="submit" name="submit" value="Geo Locate" />
<br>
<center>
<?php echo $api; ?>
</center>
</form>
could it be something wrong with my hosting service maybe?
trying to call an API that is supposed to ping a given IP address. putip addressmanually and hit the api directly through browser (by pasting url directly in browser)and see anything coming or not? if yes then there will be problem in code. Also post thaturland it's output in your question@used for skipping errors. so remove that.