0

このコードの平和を機能させようとしています。しかし、致命的なエラーが発生します。これを修正する方法がわかりません。どんな助けでも感謝します。エラーは次の行です。 $counts = $sxml-> children('http://a9.com/-/spec/opensearchrss/1.0/');

// generate feed URL
      $feedURL = "http://gdata.youtube.com/feeds/api/videos/-/{$q}
      ?orderby=viewCount&max-results={$i}";

      // read feed into SimpleXML object
      $sxml = simplexml_load_file($feedURL);

      // get summary counts from opensearch: namespace
      $counts = $sxml-> children('http://a9.com/-/spec/opensearchrss/1.0/');
      //$counts = $sxml-> children('http://www.opensearch.org/Specifications/OpenSearch/1.1');

      $total = $counts->totalResults;
      $startOffset = $counts->startIndex; 
      $endOffset = ($startOffset-1) + $counts->itemsPerPage;
4

2 に答える 2

3

simplexml_load_file has failed. It returns false (a none object) on failure.

Either your server can't access the URL, or it is returning invalid XML.

From the Manual:

Returns an object of class SimpleXMLElement with properties containing the data held within the XML document, or FALSE on failure.

于 2012-11-22T08:39:54.477 に答える