youtube api v3 mobile wap script help fro code

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    youtube api v3 mobile wap script help fro code

    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 Code:
      <?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($curlCURLOPT_HTTPAUTHCURLAUTH_ANY); curl_setopt($curlCURLOPT_SSL_VERIFYPEERtrue); curl_setopt($curlCURLOPT_RETURNTRANSFER1);   curl_setopt($curlCURLOPT_HTTPHEADER$curlheader);  $json_response curl_exec($curl);  curl_close($curl); $result json_decode($json_responsetrue); 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.'';  }    ?>

    #2
    this is what you need for your pagination:
    HTML Code:
      "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
    Advertise your mobile site for FREE with AdTwirl

    Comment


    • redrdx
      redrdx commented
      Editing a comment
      pls code this to next and back string as split the pages 5
      m not know how to use nextPageToken
      i m very confuse how to do

    • GumSlone
      GumSlone commented
      Editing a comment
      @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.

    #3
    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 &raquo;</a>';}
    else {echo '- Next &raquo;';}

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

    Comment


    • redrdx
      redrdx commented
      Editing a comment
      hi tricky my api show me "nextPageToken": "CAoQAA",
      "pageInfo": {
      "totalResults": 1000000,
      "resultsPerPage": 10

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