PHP form and Telegram API

Soul Rest

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("{$token}/sendMessage?chat_id={$chat_id}&parse_mode=html&text={$fp}","r");

if ($sendToTelegram) {
  header('Location: index.html');
} else {
  echo "Error";
1 ответ

Soul Rest Вы передаёте в телеграм указатель на файл, а не файл. Для передачи файла нужно использовать -

licensed under cc by-sa 3.0 with attribution.