I need to send an information to a public page in an online server, I am using IFTTT Platform in which when I publish a Tweet I have to send certain tweet information (User, Hashtag, content etc) to a PHP page through of the URL and save that information in a database.
Try to do this as a test, the PHP page saves the user and the IP address where the request was made, but this apparently does not work, since in the text file where it is supposed to be saved there is no nothing and testing it manually if it works.
This is the code of the applet that I use to make the request in IFTTT:
MakerWebhooks.makeWebRequest.setUrl (" link "); MakerWebhooks.makeWebRequest.setMethod ("GET"); MakerWebhooks.makeWebRequest.setContentType ("application / json"); MakerWebhooks.makeWebRequest.setBody ("? User = 'username'");
And this is the code I use in PHP to receive the information:
<?php
$usuario = null;
$nombre_archivo = "log.txt";
date_default_timezone_set("America/Mexico_City");
if(isset($_GET['usuario'])) {
$usuario = $_GET['usuario'];
}
if($archivo = fopen($nombre_archivo, "a")) {
fwrite($archivo, $usuario." con IP ".getRealIP()." \n");
fclose($archivo);
}
function getRealIP() {
if (!empty($_SERVER['HTTP_CLIENT_IP']))
return $_SERVER['HTTP_CLIENT_IP'];
if (!empty($_SERVER['HTTP_X_FORWARDED_FOR']))
return $_SERVER['HTTP_X_FORWARDED_FOR'];
return $_SERVER['REMOTE_ADDR'];
}
?>
I hope you can help me.