I need to send some data to a public php url in a online server, im using IFTTT platform were when i post a tweet i need to send the information of the tweet (Username, Hashtag, Content...) to the php url for save it in a DataBase.
i tried to do this, the php page will save the username and the IP were the request was sended, but it doesn't work.
MakerWebhooks.makeWebRequest.setUrl("http://www.mypage.com/tweet.php"); MakerWebhooks.makeWebRequest.setMethod("GET"); MakerWebhooks.makeWebRequest.setContentType("application/json"); MakerWebhooks.makeWebRequest.setBody("?user='username'");
and this is the code of the php file, it just take the user sended by the url and save it in a text file with the IP address, its just for test the webhooks, but it doesnt work
<?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'];
}
?>
Sorry about my english :P
$usuario = $_GET['usuario']; usuario should match the URL parameter 'user'.
Therefore try
$usuario = $_GET['user'];