1

このコードを私の.phpファイルに作成しました。ここで私はうまく動作するwebHookを設定しました。電報ボットスイッチのアップデート

$token = "my token"; 
$website = "https://api.telegram.org/bot" . $token . "/"; 
$updates = file_get_contents("php://input"); 
$updates = json_decode($updates, true); 
$text = $updates["message"]["text"]; 
$chatID = $updates["message"]["chat"]["id"]; 

switch($text){ 
    case "/prova_gratuita": 
     if(check($chatID)){ 
      sendMessage($chatID, "Are you sure? Demo is available only one time. Write confirm to continue"); 
      switch($text){ 
      case "confirm": 
       ... 
       break; 
      } 
     } 

第2のswitch()は機能しません。どうして?私に何ができる? 私は$textの値を更新すべきであることを知っていますが、どうすればいいのか分かりません。

+1

なぜ機能するのですか? –

+0

申し訳ありませんが、私は質問を完了していませんでした。 @u_mulder – Riccardo

答えて

0

私はこのエラーがどのように設定されているかと思います。 各ボット入力は、そのWebHookへの呼び出しです。それで$ textはそういう形になることはできません。

また、第2のスイッチの「ケース」の最初のスイッチにも含める必要があります。

$token = "my token"; 
$website = "https://api.telegram.org/bot" . $token . "/"; 
$updates = file_get_contents("php://input"); 
$updates = json_decode($updates, true); 
$text = $updates["message"]["text"]; 
$chatID = $updates["message"]["chat"]["id"]; 

switch($text){ 
    case "/prova_gratuita": 
     if(check($chatID)) sendMessage($chatID, "Are you sure? Demo is available only one time. Write confirm to continue"); 
    case "confirm": 
    ... 

} 

ボットにメッセージを送信するたびに、彼はWebHookを呼び出します。したがって、$更新の状態を変更するには、スクリプトの$ textを再起動する必要があります。

+0

私は理解しています。ありがとう – Riccardo

+0

ボットにメッセージを送信するたびに、彼はWebHookを呼び出します。 $更新の状態を変更するには、$ textでもスクリプトを再起動する必要があります。 –

+0

Sessi adesso ci sono arrivato。 Grazie di nuovo – Riccardo

関連する問題