Created
October 27, 2021 11:17
-
-
Save luizmarcus/21164bba9b127ad2f139679548930410 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//Obtém a URL do arquivo hospedado nos servidores do telegram de acordo com o ID | |
function getFileURL($id){ | |
$result = file_get_contents("https://api.telegram.org/bot".BOT_TOKEN."/getFile?file_id=".$id); | |
$response = json_decode($result,true); | |
return "https://api.telegram.org/file/bot".BOT_TOKEN."/".$response["result"]["file_path"]; | |
} | |
//Salva arquivo obtido a partir da URL do telegram | |
function saveFile($id){ | |
$file = getFileURL($id); | |
$content = file_get_contents($file); | |
$filename = explode("/", $file); | |
file_put_contents($_SERVER['DOCUMENT_ROOT']."/seubot/files/".$filename[count($filename)-1], fopen($file, 'r')); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment