Добрый день, с кроном работаю в первый раз, при запуске из панели управления хостингом командой
GET xn--80acq4ak0e.xn--80aaatxoydf6aq7i.xn--p1ai/script.php
Получаю ошибку
<b>Parse error</b>: syntax error, unexpected '[' on line <b>6</b>
Подскажете что нужно поменять, что скрипт заработал с помощью крона? без крона, просто при переходе на стр. всё работает
<?php
header('Content-Type: application/json; charset=utf-8');
$ch = curl_init();
$arr = [];
$options = array(CURLOPT_URL => 'https://flamp.ru/api/2.0/filials/70000001006315053/reviews?limit=5',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTPHEADER => array('Authorization: Bearer 2b93f266f6a4df2bb7a196bb76dca60181ea3b37')
);
curl_setopt_array($ch, $options);
$rev5 = curl_exec($ch);
$arr5 = json_decode($rev5)->reviews;
foreach ($arr5 as $rev) {
$user_url = $rev->user;
curl_setopt($ch, CURLOPT_URL, $user_url);
$user = curl_exec($ch);
$rev->user = json_decode($user)->user;
$comments_lnk = $rev->comments;
curl_setopt($ch, CURLOPT_URL, $comments_lnk);
$comments = curl_exec($ch);
$rev->comments = json_decode($comments)->comments;
$project_lnk = $rev->project;
curl_setopt($ch, CURLOPT_URL, $project_lnk);
$project = curl_exec($ch);
$rev->project = json_decode($project)->project;
$filial_lnk = $rev->filial;
curl_setopt($ch, CURLOPT_URL, $filial_lnk);
$filial = curl_exec($ch);
$rev->filial = json_decode($filial)->filial;
$photos_lnk = $rev->photos;
if(gettype($photos_lnk) == 'string') {
curl_setopt($ch, CURLOPT_URL, $photos_lnk);
$photos = curl_exec($ch);
$rev->photos = json_decode($photos)->photos;
}
$photo_lnk = $rev->photo;
curl_setopt($ch, CURLOPT_URL, $photo_lnk);
$photo = curl_exec($ch);
$rev->photo = json_decode($photo)->photo;
$arr[] = $rev;
}
while(true){
if( isset( json_decode($rev5)->next_link ) ){
$next = json_decode($rev5)->next_link;
curl_setopt($ch, CURLOPT_URL, $next);
$rev5 = curl_exec($ch);
$arr5 = json_decode($rev5)->reviews;
foreach ($arr5 as $rev) {
$user_url = $rev->user;
curl_setopt($ch, CURLOPT_URL, $user_url);
$user = curl_exec($ch);
$comments_lnk = $rev->comments;
curl_setopt($ch, CURLOPT_URL, $comments_lnk);
$comments = curl_exec($ch);
$photos_lnk = $rev->photos;
if(gettype($photos_lnk) == 'string') {
curl_setopt($ch, CURLOPT_URL, $photos_lnk);
$photos = curl_exec($ch);
$rev->photos = json_decode($photos)->photos;
}
$photo_lnk = $rev->photo;
curl_setopt($ch, CURLOPT_URL, $photo_lnk);
$photo = curl_exec($ch);
$rev->photo = json_decode($photo)->photo;
$rev->comments = json_decode($comments)->comments;
$rev->user = json_decode($user)->user;
$arr[] = $rev;
}
} else {
break;
}
}
file_put_contents('data.json', json_encode($arr));
file_put_contents('test.json', json_encode($arr));
?>