Youtube API 2.0 サポート終了のため、検索結果に「UKY3scPIMd8」
動画が追加されます。 API3.0のOath認証しないサーチのプログラム
<?php
//YoutubeClass.php ver 2
//youtube api 3.0
//https://www.youtube.com/watch?v=UKY3scPIMd8
$g=$_GET['g'];
if($g){
 $x=new YoutubeAPI($g);
 $x->link();
}else{
  exit('88');
}
class youtubeapi {
  public $url;
  public function youtubeapi($key){
   $API_URL = 'https://www.googleapis.com/youtube/v3/search?';
   $para['key'] = 'AI********************************Ao';
   $para['part'] = 'id';
   $para['q'] = $key;
   $para['type'] = 'video';
   $para['maxResults'] = 3;
   $this->url = $API_URL.http_build_query($para);
  }
  
  public function link(){
    $ll=array();
    $data = file_get_contents($this->url);
    $xdata = json_decode($data ,true);
    foreach ($xdata['items'] as $key=>$val){
      $ll[count($ll)]=$val['id']['videoId'];
    }
    unset ($key);
    unset ($val);
    echo implode('|',$ll);
  }
}
?>