2

I'm making a telegram bot. And I want to receive a photo and show it to the user again. For example, take a photo of the user and send it back with text to user. I am taking a file_path, but when I call the "sendPhoto" function, the photo will not be sent. For my exam, I put up other photos and replied as good, but the user's photo did not send.

My code:

$photos = $update["message"]["photo"];
if($photos!=null){
    getPhoto($chatid, $token, $photos);
}

function sendPhoto($id, $title, $picture){
    if(strpos($title, "\n")){
        $title = urlencode($title);
    }

    if(strpos($picture, "\n")){
        $picture = urlencode($picture);
    }

    return api_request("/sendPhoto?chat_id=".$id."&photo=".$picture."&caption=".$title);
}

function getPhoto($id,$token, $photo){
    $result = api_request("/getFile?file_id=".end($photo)["file_id"]);
    $result = json_decode($result ,TRUE);
    $file_name = $result["result"]["file_path"];
    $file_path = "https://api.telegram.org/file/bot".$token."/".$file_name;
    sendPhoto($id, "your picture?", $file_path );

}
morteza
  • 33
  • 1
  • 4

0 Answers0