skeezr
But i don't know how to show the image after with the file_get_contents and don't know about crud request or redis so xd
public function forge($request)
{
$redis = Redis::connection();
$format = pathinfo($request, PATHINFO_EXTENSION);
switch ($format)
{
case 'png':
default:
header('Content-Type: image/png');
break;
}
$url = "http://staticns.ankama.com/";
$url .= $request;
$hash = md5($request);
$data = $redis->get("dofus:forge:$hash");
if ($data)
{
print $data;
}
else
{
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_COOKIESESSION, true);
$result = curl_exec($curl);
$code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
if ($code == 404)
{
header("HTTP/1.1 404 Not Found");
header('Content-Type: plain/text');
print $result;
}
else
{
$redis->set("dofus:forge:$hash", $result);
print $result;
}
curl_close($curl);
}
}
This is the code from https://github.com/LuaxY/EreziaAPI/blob/master/app/controllers/ForgeController.php
The $request is equal to : "dofus/renderer/look/'.bin2hex($entityLookString).'/face/1/35_35-0.png'"
In fact the code simply save the binary data of the image get from the Dofus api in a Redis database, you can save where you like, and can save safely because the result of a string of look never change ^^
PD: It's curl sorry bad typo xD