Php-img-bot-whatsapp

download gambar yang dikirim ke bot Whatsapp


<?

header("Content-type:application/json");
$bx = $_GET['bx'] ;
$id = $_GET['id'] ;
$num = $_GET['num'] ;

if(empty($num)){$num="biston";}
if(empty($bx) || empty($id)){echo '{"status":"null"}'; exit();}
$idm = $id.".jpg";
$url1 = "https://graph.facebook.com/v17.0/".$id;
$headers = [
    'Authorization: Bearer '.$bx,
];

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$res = curl_exec ($ch);
curl_close ($ch);
$js = json_decode($res,true);
$urlx = $js['url'];


    $fp = fopen ($idm, 'w+');              // open file handle
    $ch = curl_init($urlx);
    curl_setopt($ch, CURLOPT_FILE, $fp);          // output to file
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
    curl_setopt($ch, CURLOPT_TIMEOUT, 1000);      // some large value to allow curl to run for a long time
    curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0');
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    curl_exec($ch);
    curl_close($ch);                              // closing curl handle
    fclose($fp);    

sleep(5);
$idm = "https://biston.web.id/".$idm ;
echo '{"img":"'.$idm.'","num":"'.$num.'"}';

?>

tampilkan semua gambar


try { 
    unlink("error_log"); 
} catch(Exception $e) { }

$saya = $_GET['saya'] ;
if($saya!="ganteng"){echo 'biston was here'; exit();}


 $all_files = glob("*.jpg");
 for ($i=0; $i<count($all_files); $i++)
 {
  $image_name = $all_files[$i];
  echo $image_name.'<br><img width="250" height="150" src="'.$image_name .'" alt="'.$image_name.'"/>'."<br/><br/>";
 }