-1

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

Mojo Allmighty
  • 793
  • 7
  • 18
Batres35
  • 1
  • 2
  • 1
    You're currently sending a `GET` request to `tweet.php?user=username`. Do you have PHP code that does something with a `$_GET['user']` variable? If so, please share that, thus forming a [**minimal, complete, and verifiable example**](http://stackoverflow.com/help/mcve), along with clearly stating what your desired **result** is. For further information, please refer to the help article regarding [**how to ask good questions**](http://stackoverflow.com/help/how-to-ask), and take the [**tour of the site**](http://stackoverflow.com/tour) :) – Obsidian Age Nov 06 '18 at 23:04
  • Yes, i recieve the variable with a GET, i put the code of the file php in the post, thanks. – Batres35 Nov 07 '18 at 04:51

1 Answers1

0

$usuario = $_GET['usuario']; usuario should match the URL parameter 'user'.

Therefore try

$usuario = $_GET['user'];

Bicycle
  • 63
  • 9