Answer the question
In order to leave comments, you need to log in
php + json how to get all id's?
Hello, please help me 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'] ;
}
The value of kinopoisk_id is about 9k.
kinopoisk_id is output as a string.
How to substitute each id and display info by 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_en'] ;
echo $full_info['year'] ; echo '';
echo $full_info['poster'] ; echo '';
}
Put on the right path. Thanks in advance.
Answer the question
In order to leave comments, you need to log in
Try like 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 '<br>';
echo $full_info['year']; echo '<br>';
echo $full_info['poster']; echo '<br>';
echo '<hr>';
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question