亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何“刷新”file_get_contents('php://input') 的狀態?

如何“刷新”file_get_contents('php://input') 的狀態?

PHP
喵喔喔 2021-07-06 13:15:49
我正在嘗試使用 PHP 代碼為電報做 BOT?;旧嫌脩舯仨氃诓迦胫g進行選擇:1)姓名 2)姓氏 3)地址選擇姓氏,他必須寫下他的姓氏,我想將其存儲到變量中,但是,如果我使用,$update = file_get_contents('php://input')我總是讀“姓氏”(這是用戶的第一個輸入)所以我認為我的問題是:如何file_get_contents('php://input')在我的程序的特定“時刻”中更改內容?請閱讀我的代碼以獲取更多詳細信息,非常感謝!??!    <?php$botToken = "MYTOKEN"; //token $website = "https://api.telegram.org/bot".$botToken;$update = file_get_contents('php://input'); //updates from telegram (JSON format)$update = json_decode($update, TRUE); $chatId = $update['message']['from']['id']; $text = $update['message']['text']; switch($text)    {    case "name";    sendMessage ($chatId,"You write name");    break;    case "surname";    sendMessage ($chatId,"You write surname");     sendMessage ($chatId,"Insert your surname");                 /* here is my problem: what i have to do to "read" what the                 user write now? i want to store his surname into a new                 variable*/    break;    case "address";    sendMessage ($chatId,"You write address");    break;     default;    sendMessage ($chatId,"You don't write a valid command");    break;         }function sendMessage($chatId,$text)    {        $url = $GLOBALS[website]."/sendMessage? chat_id=$chatId&text=".urlencode($text);        file_get_contents($url);    }?>
查看完整描述

1 回答

  • 1 回答
  • 0 關注
  • 158 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號