Php + json to get all id?


Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/public_html/qa-theme/donut-theme/qa-donut-layer.php on line 274
0 like 0 dislike
21 views
Hello help to implement.

$url = file_get_contents ('https://newvideo.tv/api/category-list?api_key=
[your_api_key]&cat=film');
$decode_url = json_decode($url, true);

foreach($decode_url['data'] as $id){
echo $id['kinopoisk_id'] ;

}

Values kinopoisk_id about 9 K.
kinopoisk_id displayed string.
5aeecda2e5cdc754717540.jpeg
How to substitute each id and display the info on the id ?

$url2 = file_get_contents ('https://newvideo.tv/api/videos?api_key=
[your_api_key]&kinopoisk_id='.$id['kinopoisk_id']);
$decode_url2 = json_decode($url2, true);

foreach($decode_url2['data'] as $full_info){
echo $full_info['title_ru'] ; echo ";
echo $full_info['year'] ; echo ";
echo $full_info['poster'] ; echo ";
}

Put on the right path. Thanks in advance.
by | 21 views

2 Answers

0 like 0 dislike
Try this:
$url = file_get_contents ('https://newvideo.tv/api/category-list?api_key=[your_api_key]&cat=film'); $decode_url = json_decode($url, true); foreach($decode_url['data'] as $id){ $currentId = $id['kinopoisk_id'] ; $url2 = file_get_contents ('https://newvideo.tv/api/videos?api_key=[your_api_key]&kinopoisk_id='.$currentId); $decode_url2 = json_decode($url2, true); foreach($decode_url2['data'] as $full_info){ echo $full_info['title_ru']; echo '
'; echo $full_info['year']; echo '
'; echo $full_info['poster']; echo '
'; echo ''; } }


UPD
Only 9K requests for additional information can take quite a long time. To generate pages on the fly this is not an option.

UPD2
In the second query, I forgot to change $id['kinopoisk_id'] $currentId
by
0 like 0 dislike
Thank you very much for your help.
by

Related questions

0 like 0 dislike
1 answer
0 like 0 dislike
1 answer
asked May 22, 2019 by Sergey43
0 like 0 dislike
2 answers
asked May 12, 2019 by san_jorich
0 like 0 dislike
1 answer
asked May 22, 2019 by KenKup
110,608 questions
257,187 answers
0 comments
40,796 users