サーバーに保存する前に、リモート ファイルが変更されているかどうかを確認したいと考えています。まず、リモート ファイルとローカル ファイルの間で md5_file を使用して比較を実行する前に、ファイルが存在するかどうかを確認しましたが、これは非常に遅いです。これを確認するより速い方法はありますか?
$channelName = htmlspecialchars($_GET['channel'], ENT_QUOTES);
$json_array = json_decode(file_get_contents('http://api.hitbox.tv/media/live/'.strtolower($channelName)), true);
$getImage = $json_array['livestream'][0]['channel']['user_logo_small'];
$imageURL = "http://edge.vie.hitbox.tv/$getImage";
$imagePath = str_replace("/static/img/channel/", "", $getImage);
$ImageExtension = substr( strrchr($imagePath, '.'), 1);
$imageOutput = "images/$channelName.".$ImageExtension;
if (file_exists($imageOutput)) {
if (md5_file($imageURL) != md5_file($imageOutput)) {
file_put_contents($imageOutput, file_get_contents($imageURL));
}
} else {
file_put_contents($imageOutput, file_get_contents($imageURL));
}
誰かが私を少し助けてくれるか、正しい方向に導いてくれるかもしれません^^
よろしく、カズト