( ′∀`)σ≡σ☆))Д′)レ(゚∀゚;)ヘ=З=З=Зε≡(ノ´_ゝ`)ノ
<?php
/*$term = $templateDetails["0"]["about"];
$term = urlencode("best picture for ".$term);*/
$term = $aiResults['editor']['imageSearchTerm'];
$term = urlencode($term);
$curl = curl_init();
$lapage =$im - 1;
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.pexels.com/v1/search?query=$term&per_page=3&orientation=landscape&color=$bgColor",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"Authorization: SnJeKdzoLJiTT1Ge8rud21n5uvhWZPBTT0I9AwBtNSyG1pQLAJA5sRqh"
),
));
$responsePexel = curl_exec($curl);
$err = curl_error($curl);
$randMe = rand(0,5);
curl_close($curl);
if ($err) {
} else {
$dataPexel = json_decode($responsePexel , true);
$pic = $dataPexel["photos"][$lapage]["src"]["large"];
$filename = strtolower(preg_replace('/[^A-Za-z0-9-]+/', '-', $dataPexel["photos"][$lapage]["alt"])).".jpg";
$saveLocation = "/var/www/html/v/uploads/gthumbs/$filename";
$image_data = file_get_contents($pic);
file_put_contents($saveLocation, $image_data);
/* $crop = $data["backgroundImage"]['width'] /$data['objects'][$key]['height'].":1";
$width = ($data["backgroundImage"]['width'] * $data['objects'][$key]['scaleX']);
$height = ($data["backgroundImage"]['height']* $data['objects'][$key]['scaleY']);
list($newWidth, $newHeight) = getimagesize($saveLocation);
$newWidth2 = $newWidth -1;
$newHeight2 = $newHeight -1;*/
list($newWidth, $newHeight) = getimagesize($saveLocation);
$srcPexel="https://www.thebrand.ai/taswira.php?image=/v/uploads/gthumbs/".basename($saveLocation);
}
?>