2022-07-07 16:26:33
if($message->photo){
bot('sendmessage',[
'chat_id'=>$YOUSFKH13,
'text'=>"Yuborilmoqda, biroz kuting. . . ",
]);
define('API_KEY', $API_KEY);
$data = json_decode(json_encode($message),true);
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://api.telegram.org/bot'. API_KEY .'/getfile?file_id='.$data["photo"][count($data["photo"]) -1]["file_id"] ,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'GET',
));
$response = json_decode(curl_exec($curl), true);
curl_close($curl);
if($response["ok"]){
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://api.remove.bg/v1.0/removebg',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => array('image_url'=> "https://api.telegram.org/file/bot". API_KEY ."/".$response["result"]["file_path"],
'size' => 'auto'),
CURLOPT_HTTPHEADER => array('X-Api-Key: ZQ5hxrWfVr46VpL2RD4Hm4ER'),
));
$response = curl_exec($curl);
curl_close($curl);
if(json_decode($response, true)["errors"]){
//@abdulloev_shavkat
bot("sendmessage",["chat_id"=>$chat_id,"text"=>json_decode($response, true)["errors"][0]["title"]]);
}else{
file_put_contents("@ius_te.png", $response);
bot("senddocument", [
"chat_id"=>$shavkat,
"document"=>new CURLFILE('./@ius_te.png')
]);
unlink("./@ius_te.png");
}
}
}
//kelayotgan Qurbon bayrami muborak bolsin
247 views 1 yil 20 oy 88 hafta 616 kun 14790 соат 887046 minut, 13:26