<?php
$message = file_get_contents("php://input");
$arrayMessage = json_decode($message, true);
$token = "my token";
$chat_id = $arrayMessage['message']['from']['id'];
$command = $arrayMessage['message']['text'];
$photoID = $arrayMessage['message']['photo'][2]['file_id'];
$telegram_file_path = "https://api.telegram.org/bot" . $token . "/getFile?file_id=" . $photoID;
$file_url = json_decode(file_get_contents($telegram_file_path) ,true);
$photo = $file_url['result']['file_path'];
$photoPath = 'https://api.telegram.org/file/bot'.$token.'/'.$photo;
$fileName = 'userImage.jpg';
file_put_contents($fileName, fopen($photoPath, 'r'));
$caption = "تصویر با موفقیت دریافت شد";
$url = "https://api.telegram.org/bot" . $token . "/sendMessage?chat_id=" . $chat_id . "&text=" . $text;
file_get_contents($url);
?>