0

I am trying to send notification to my channel but without reply_markup i could send but with markup, I couldnt. Hakre your answer didnt work. Using urlencode i couldn`t send anything also.

$chefbotToken = "XXXXXXXXXX:AAHnUV8fk2gIp4_wudVcuyaxmuxsCPPMPwc";
$canallink= "@zehnuz";
$replyMarkup = array(
    'keyboard' => array(
        array("A", "B")
    )
);
$encodedMarkup = json_encode($replyMarkup);

$yangilik = $title.$shart;
$chef_bot_url    = "https://api.telegram.org/bot".$chefbotToken;
$url = $chef_bot_url."/sendMessage?chat_id=".$canallink."&text=".urlencode($yangilik)."&reply_markup=".urlencode($encodedMarkup);
file_get_contents($url);
  • If you construct an URL, you need to encode values appropriately. That is true for all parts of that URL and includes JSON encoded data which is not already URL encoded. – hakre Jun 18 '17 at 09:26
  • @hakre, the issue presented in this question is not the URL encoding. He tried to send a JSON over a GET URL, which is not a correct thing to do. Also, he did not ask how to URL encode arrays in PHP, he asked for help identifying the problem. – Catalyst Jun 18 '17 at 09:37
  • There is no issue sending JSON (as any other string) over a GET URL. Especially as this is a small string. The problem in his code (at least one) is that he didn't encode an URL parameter properly - do you see a different Q&A resource that is in context here? If so, please share, there can be more than one reference Q&A linked. – hakre Jun 18 '17 at 09:41
  • $url = $chef_bot_url."/sendMessage?chat_id=".$canallink."&text=".urlencode($yangilik)."&reply_markup=".urlencode($encodedMarkup); file_get_contents($url); – Ilyos olimov Jun 18 '17 at 09:50
  • but it didnt work – Ilyos olimov Jun 18 '17 at 09:54

0 Answers0