title: Get YouTube video title in PHP
body: <p>In one of my applications I am saving a YouTube video's id... Like &quot;A4fR3sDprOE&quot;. I have to display its title in the application. I got the following code for getting its title and also it's working fine.</p>
  <p>Now the problem is if any error occurred (in case of a delete of the video) PHP is showing an error. I hust added a condition. But still it's showing the error.</p>
  <pre><code>foreach($videos as $video) {
  
      $video_id = $video-&gt;videos;
      if($content=file_get_contents(&quot;http://youtube.com/get_video_info?video_id=&quot;.$video_id)) {
          parse_str($content, $ytarr);
  
          $myvideos[$i]['video_title']=$ytarr['title'];
  
      }
      else
          $myvideos[$i]['video_title']=&quot;No title&quot;;
  
      $i++;
  }
  
  return $myvideos;
  </code></pre>
  <p>In case of an error it's dying with the following:</p>
  <p>Severity: Warning</p>
  <p>Message: file_get_contents(<a href="http://youtube.com/get_video_info?video_id=A4fR3sDprOE" rel="nofollow noreferrer">http://youtube.com/get_video_info?video_id=A4fR3sDprOE</a>) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.0 402 Payment Required</p>
  <p>Filename: models/webs.php</p>
  <p>Line Number: 128</p>