1
Ich möchte Cache von Json Ergebnis von einer Locke, aber Fehler Funktion Grabe ($ url, $ dir, $ Umbenennen, $ Zeit = '0', $ format = 'Json') {PHP CURL und Cache von JSON Ergebnis
$tmp_dir = 'cache';
$dir=$tmp_dir.$dir;
$rename=md5($rename);
$file=$dir.'/'.$rename.'.'.$format;
if(!is_dir($dir)) {mkdir($dir, 0755);}
$cachetime=(60*$time);
if (file_exists($file) && time() - $cachetime < filemtime($file))
{
$rawdata=file_get_contents($file);
return $rawdata;
}else
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$uaa = $_SERVER['HTTP_USER_AGENT'];
curl_setopt($ch, CURLOPT_USERAGENT, "User-Agent: $uaa");
$rawdata=curl_exec ($ch);
curl_close ($ch);
if($rawdata){
$fp = fopen("$file",'w');
fwrite($fp, $rawdata);
fclose($fp);
return $rawdata;
}
}}
eror sagen Ausgabe:
Fatal error: Uncaught ArgumentCountError: Too few arguments to function grabe(), 1 passed in /home/hdmoviewap/public_html/index.php on line 182 and at least 3 expected in /home/hdmoviewap/public_html/core/init.php:3 Stack trace: #0 /home/hdmoviewap/public_html/index.php(182): grabe('https://www.goo...') #1 {main} thrown in /home/hdmoviewap/public_html/core/init.php on line 3
meine 182 Linie index.php blies
$grab=grabe('https://www.googleapis.com/youtube/v3/search?key='.$key.'&part=snippet&order=relevance&maxResults=20&q=Latest+Bollywood+Video&type=video');
wie es lieber beheben? –
Pass einfach zwei weitere Params auf. Sie machen $ grab = grabe (url) und müssen $ grab = grabe (url, 'directory', 'rename') ausführen – jeprubio
wo in Zeile 182 in index.php? –