<?php

//TELEGRAM
$token = "887175490:AAE2MdfsVxde8PmkY4KROJrT_1PxPyBxl2w";
$chatID = "1090942331";
$messaggio = "Hi";

$update = file_get_contents('php://input');
$update = json_decode($update, TRUE);

$chatID = $update['message']['from']['id'];
$firstname = $update['message']['from']['id'];
$username = $update['message']['from']['id'];
$text = $update['message']['text'];

if($text == "/start"){
	$messaggio = "Hi, How are you?";
	$keyboard = array();
	sendMessage($chatID,$messaggio,$token);
}

//sendMessage($chatID,$messaggio,$token);

function sendMessage($chatID,$messaggio,$token){
	echo "sending message to " . $chatID . "\n";

	$url = "https://api.telegram.org/bot" . $token . "/sendMessage?chat_id=" . $chatID;
	$url = $url . "&text=" . urlencode($messaggio);
	$ch = curl_init();
	$optArray = array(
			CURLOPT_URL => $url,
			CURLOPT_RETURNTRANSFER => true
	);
	curl_setopt_array($ch, $optArray);
	$result = curl_exec($ch);
	curl_close($ch);
	return $result;
}

?>