PHP form and Telegram API

I made a PHP code using telegram API. Code have to take value from html contact form (action=”telegram.php”) and put it to .vcf file (VCard) and send it to group in telegram. But if I send form, in chat comes a message “Resource Id”. Please tell me where I was wrong?

$name = $_POST['user_name'];
$phone = $_POST['user_phone'];
$email = $_POST['user_email'];
$token = "token";
$chat_id = "chat";
$arr = array(
  'Имя пользователя: ' => $name,
  'Телефон: ' => $phone,
  'Email' => $email

foreach($arr as $key => $value) {
  $txt .= "<b>".$key."</b> ".$value."%0A";
$fp = fopen("file.vcf","w");
fwrite($fp, $txt);

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

if ($sendToTelegram) {
  header('Location: index.html');
} else {
  echo "Error";

Источник: https://ru.stackoverflow.com/questions/802998/php-form-and-telegram-api

Тебе может это понравится...

Добавить комментарий