linux - PHP YouTube Api V3 MaxResults Not Working -


i implemented google api app using youtube service youtube videos. works expected far getting results reason maxresults not working. display results if set example 15 shows endless number of results on page.

    <?php     //load google api client     //added google api support 01/21/2016     set_include_path(get_include_path().path_separator.'vendor/google/apiclient/src');       //=================================================================================     //start google api integration     //=================================================================================     $htmlbody = <<<end     <form method="get">     <div>     search youtube video<br>     <input type="search" id="q" name="q" placeholder="search" size="30">     </div>     <input type="submit" value="search">     </form>     end;      if ( $_get['q'] )      {     require_once 'google/client.php';     require_once 'google/service/youtube.php';       $developer_key = 'removed obvious reasons';    $client = new google_client();   $client->setdeveloperkey($developer_key);    // define object used make api requests.   $youtube = new google_service_youtube($client);    try {     // call search.list method retrieve results matching specified     // query term.     $searchresponse = $youtube->search->listsearch('id,snippet', array(       'q' => $_get['q'],       'maxresults' => 15,       'type' => 'video',     ));      $videos = '';      // add each result appropriate list, , display lists of     // matching videos.     $i = 0;     foreach ($searchresponse['items'] $searchresult)      {       switch ($searchresult['id']['kind'])        {         case 'youtube#video':           $videotitle = $searchresult['snippet']['title'];             $videoid = $searchresult['id']['videoid'];            $videoembed = '<iframe width="150" height="150" src="http://www.youtube.com/embed/'.$videoid.'?autoplay=0&hd=1&vq=hd720" frameborder="0" allowfullscreen></iframe>';             $htmloutput .= '           <table width="50%" align="center">           <tr>             <th colspan="2">'.$i.'. '.$videotitle.'</th>           </tr>           <tr>             <td width="40%">'.$videoembed.'</td>             <td width="60%" align="center">                 <form action="index.php" method="post" id="conversionform">                     <input type="hidden" name="youtubeurl" value="'.$videoid.'">                         <input type="hidden" value="320" name="quality">                         <input type="submit" name="submit" value="create mp3 file">                 </form>              </td>           </tr>           </table>           ';           $videos .= '<li>'.$htmloutput.'</li>';           break;       }       $i++;     }      $htmlbody .= <<<end     <h3>videos</h3>     <ul>$videos</ul> end;   } catch (google_service_exception $e) {     $htmlbody .= sprintf('<p>a service error occurred: <code>%s</code></p>',       htmlspecialchars($e->getmessage()));   } catch (google_exception $e) {     $htmlbody .= sprintf('<p>an client error occurred: <code>%s</code></p>',       htmlspecialchars($e->getmessage()));   } }      //=================================================================================     //end google api integration     //=================================================================================  ?> 

wow must tired. figured out.

changed

$htmloutput .= '

to

$htmloutput = '

that fixed problem having.

thank guys!


Comments

Popular posts from this blog

android - Why am I getting the message 'Youractivity.java is not an activity subclass or alias' -

python - How do I create a list index that loops through integers in another list -

c# - “System.Security.Cryptography.CryptographicException: Keyset does not exist” when reading private key from remote machine -