title: Telegram request "fopen failed to open stream: HTTP request failed! HTTP/1.1 400 Bad Request"
body: <p>I am trying to send messages to my telegram bot. Exactly name variable can't allow me to do it.</p>
  <pre class="lang-php prettyprint-override"><code>    $arr = array(
        $phoneFieldset =&gt; $phone,
        $nameFieldset =&gt; $name,
        $messageFieldset =&gt; $message,
      );
      foreach($arr as $key =&gt; $value) {
        $txt .= &quot;&lt;b&gt;&quot;.$key.&quot;&lt;/b&gt; &quot;.$value.&quot;%0A&quot;;
      };
      
      $request = &quot;https://api.telegram.org/bot{$token}/sendMessage?chat_id={$chat_id}&amp;parse_mode=html&amp;text={$txt}&quot;;
      
      echo $request;
      
      $sendToTelegram = fopen($request,&quot;r&quot;);
  </code></pre>
  <p>The request echo output, when the script fails:</p>
  <pre><code>https://api.telegram.org/botMYTOKEN/sendMessage?chat_id=-449128489&amp;parse_mode=html&amp;text=Телефон: 123%0AИмя: de%0AСообщение: 123213%0A
  </code></pre>
  <blockquote>
  <p>Warning: fopen(<a href="https://api.telegram.org/botMYTOKEN/sendMessage?chat_id=-449128489&amp;parse_mode=html&amp;text=" rel="nofollow noreferrer">https://api.telegram.org/botMYTOKEN/sendMessage?chat_id=-449128489&amp;parse_mode=html&amp;text=</a><b>Телефон: </b> 123%0A<b>Имя: </b> de%0A<b>Сообщение: </b> 123213%0A): failed to open stream: HTTP request failed! HTTP/1.1 400 Bad Request in C:\nginx\html\scripts\php\send-message-to-telegram.php on line 61
  Ошибка. Сообщение не отправлено!</p>
  </blockquote>
  <p>Line 61 is the one containing the <code>fopen()</code>.</p>
  <p>The request echo output, when the script works:</p>
  <pre><code>https://api.telegram.org/botMYTOKEN/sendMessage?chat_id=-449128489&amp;parse_mode=html&amp;text=Телефон: 123123%0AСообщение: 1213123%0A
  </code></pre>