R
R
razzakov2019-01-14 00:13:00
PHP
razzakov, 2019-01-14 00:13:00

Sends a request locally, but not on the Internet?

Sends an application on the local, but not on the Internet.
Error appears on the Internet, everything is fine on the local, why?
Help! Very necessary! Thanks in advance!

<?php

$name = $_POST['fio'];
$phone = $_POST['phone'];
$token = "630683258:AAF18XQlE2SFVid3y4P7yGvqJxMFvyjQUM4";
$chat_id = "-361496163";
$arr = array(
  'Ф.И.О.: ' => $name,
  'Телефон: ' => $phone,
);

foreach($arr as $key => $value) {
  $txt .= "<b>".$key."</b> ".$value."%0A";
};

$sendToTelegram = fopen("https://api.telegram.org/bot{$token}/sendMessage?chat_id={$chat_id}&parse_mode=html&text={$txt}","r");

if ($sendToTelegram) {
  header('Location: thank-you.html');
} else {
  echo "Error";
}
?>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton, 2019-01-14
@karminski

Check the PHP configuration on your server. Maybe the allow_url_fopen directive is disabled.
php.net/manual/ru/filesystem.configuration.php

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question