I am making myself crazy trying to solve this problem.
I have a PHP webhook page like this:
function processMessage($message)
{
if (isset($message['text'])) {
$text = $message['text'];
if (strpos($text, "/start") === 0) {
apiRequestJson("sendMessage", array(
'chat_id' => $chat_id,
"text" => 'Benvenuto ' . $firstname . ' ' . $lastname . ' sul BOT di MIMANCHITU, dimmi cosa vuoi fare?',
'reply_markup' => array(
'keyboard' => array(array('/GUIDE', '/DOMANDE')),
'one_time_keyboard' => true,
'resize_keyboard' => true
)
));
} else if ($text === "/DOMANDE") {
apiRequest("sendMessage", array(
'chat_id' => $chat_id,
"text" => 'Inserisci la parola da cercare tra le risposte della Dottoressa [' . $azione . '] XXX:'
));
} else if (strpos($text, '/') !== true) {
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_RETURNTRANSFER => true,
CURLOPT_VERBOSE => true,
CURLOPT_URL => 'http://www.domain.it/bot/search_dom.php',
CURLOPT_POSTFIELDS => array(
'parola' => $text
)
));
$resp = curl_exec($curl);
$obj = json_decode($resp);
curl_close($curl);
foreach ($obj as $value) {
apiRequest(......));
}
} else if ($text === "/GUIDE") {
apiRequest("sendMessage", array(
'chat_id' => $chat_id,
"text" => 'Cerca una parola per visualizzare i contenuti trovati tra le Guide al Sesso di MIMANCHITU:'
));
}
}
}
The user has two choices:
- clicking
/GUIDE
to search, writing a word, into mysql db with tutorial ... - clicking
/DOMANDE
to search, writing a word, into mysql db with question...
My problem is how to check if user searches in /GUIDE
or /DOMANDE
after choosing the button from a custom keyboard! I was thinking about setting a PHP SESSION parameter, but that doesn't work!
Any ideas?