rapid-porn

फ़्री
द्वारा yourComputerGuy | अपडेट किया गया il y a 3 mois | Entertainment
लोकप्रियता

9.5 / 10

लेटेंसी

749ms

सेवा का स्तर

93%

Health Check

N/A

सभी चर्चाओं पर वापस जाएं

in what format the image came from API, i cant render it

Rapid account: Eugene Veprytskyi
eugene.veprytskyi
il y a 8 mois

issue

Rapid account: Jeankassiocheib 3
jeankassiocheib3 Commented il y a un mois

If you using PHP:

$images = new Images;

	$file = dirname(__FILE__) . "/media/media.jpg";
	
	$image = $images->getImage($term);
	
	if($image !== false){
		file_put_contents($file, $image);
	}

/*
Class with functions
*/
class Images{
private function isNotJson(string){ json_decode(string);
return json_last_error() !== JSON_ERROR_NONE;
}

public function getImage($term){
	
	$curl = curl_init();

	curl_setopt_array($curl, [
		CURLOPT_URL => "https://rapid-porn.p.rapidapi.com/photo?category=". $term,
		CURLOPT_RETURNTRANSFER => true,
		CURLOPT_ENCODING => "",
		CURLOPT_MAXREDIRS => 10,
		CURLOPT_TIMEOUT => 30,
		CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
		CURLOPT_CUSTOMREQUEST => "GET",
		CURLOPT_HTTPHEADER => [
			"X-RapidAPI-Host: rapid-porn.p.rapidapi.com",
			"X-RapidAPI-Key: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
		],
	]);

	$response = curl_exec($curl);
	$err = curl_error($curl);

	curl_close($curl);

	if($err){
		return false;
	}else{
		
		if($this->isNotJson($response)){
			return $response;
		}else{
			return false;
		}
		
	}
	
}

}

चर्चा में शामिल हों - नीचे टिप्पणी जोड़ें:

नई टिप्पणियाँ पोस्ट करने के लिए लॉग इन / साइनअप करें