youtube api v3 mobile wap script help fro code

Started on the old forum in May 2015 · view the original in the archive · old links redirect here

2 replies · 1,141 views · started 11 years ago · 1 min read

3 participants
redrdx Developer · 80 posts #1

m try to fetch the pagination from json but my hand off now so anyone can complete the pagination result from it youtube api v3

  <?php $url="https://www.googleapis.com/youtube/v3/search?order=rating&part=snippet&q=cars&maxResults=10&key=AIzaSyBCLxHPgsISSgx0asL7dBit5u-1NIfFX3w&pageToken";  $curl = curl_init($url);  curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_ANY); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, true); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);   curl_setopt($curl, CURLOPT_HTTPHEADER, $curlheader);  $json_response = curl_exec($curl);  curl_close($curl); $result = json_decode($json_response, true); foreach ($result['items'] as $data ){ $vtittle = $data['snippet']['title']; $vid = $data['id']['videoId'];             $videoThumb = $data['snippet']['thumbnails']['default']['url'];     print'<br>'.$vtittle.'<br><img src="'.$videoThumb.'" /><br>'.$vid.'';  }    ?> 

Life On Clicks External image (may be gone) Get More Tricks Add Me On Gtalk ID Rdxmob@gmail.com

GumSlone Administrator Principal · 1,690 posts #2

this is what you need for your pagination:

  "pageInfo": {   "totalResults": 1000000,   "resultsPerPage": 10  } 

it seems that it is only possible to have next page and previous page as pagination in this api but you could fetch 50 results from youtube, cache those results, split those results into 5 pages, and use nextPageToken to fetch next 50 results, cache them and split into next 5 pages and so on

👍 1
Share

Advertise your mobile site for FREE with AdTwirl

External image (may be gone)

tricky Junior · 36 posts #4

try like this $Next=$json->nextPageToken; $Prev=$json->prevPageToken;

if(!empty($_GET['q'])){$next='index.php?q='.$_GET['q'].'&page='.($Next).''; $prev='index.php?q='.$_GET['q'].'&page='.($Prev).'';}else{$next='index.php?page='.($Next).''; $prev='index.php?page='.($Prev).'';}

if (!$Next=='') {echo'- <a href="'.$next.'">Next »</a>';} else {echo '- Next »';}

if (!$Prev=='') {echo'<a href="'.$prev.'">« Prev</a> ';} else{echo '« Prev ';}

👍 1
Share
GumSlone Administrator Principal · 1,690 posts #5

@redrx i'm not going to code it for you, i gave you an idea, you should try to code it yourself and if you have some problems with coding, you can post your code here and we will find together a solution for it.

Advertise your mobile site for FREE with AdTwirl

External image (may be gone)

redrdx Developer · 80 posts #6

hi tricky my api show me "nextPageToken": "CAoQAA", "pageInfo": { "totalResults": 1000000, "resultsPerPage": 10

can u tell me snippet code to print "nextPageToken": "CAoQAA",

Life On Clicks External image (may be gone) Get More Tricks Add Me On Gtalk ID Rdxmob@gmail.com

Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close