2012-02-24 6 views
1

나는 youtube에서 PHP의 youtube-api를 사용하여 사용자로부터 좋아하는 비디오를 읽을 수 있기를 원합니다. 지금까지이있다 :YouTube에서 사용자의 즐겨 찾기 비디오를 보려면 어떻게해야합니까? php로 youtube api를 사용하는 방법

의 index.php`

<?php 
    require_once 'Zend/Loader.php'; // the Zend dir must be in your include_path 
    Zend_Loader::loadClass('Zend_Gdata_YouTube'); 
    $yt = new Zend_Gdata_YouTube(); 

    $yt->setMajorProtocolVersion(2); 
    $favoritesFeed = $yt->getUserFavorites('cartmanland911'); 

    foreach($activityFeed as $activityEntry) { 
     $title = $activityEntry->getVideoTitle(); 
     echo "favorited video " . $title . '<br/>'; 
    } 
?>` 

zend framework는 index.php 파일과 같은 폴더에 있고 워크로드 확인을 클릭합니다. echo $favoritesFeed->count(); 출력 호출

호출 echo $favoritesFeed->getDOM()->hasChildNodes(); 출력 또한 1

올 6

그래서, 질문은 내가 각각의 이름을 읽습니까 어떻게 (내가 6 개 좋아하는 동영상이) 좋아하는 비디오?

편집 : 위의 다른 해결책을 추가했습니다.

답변

1

당신이 할하기 위해 PHP는 XQuery 확장을 고려하는 것이 좋습니다 :

import module namespace http = "http://expath.org/ns/http-client"; 

declare namespace a = "http://www.w3.org/2005/Atom"; 

let $req := <http:request method="GET" href="http://gdata.youtube.com/feeds/base/users/cartmanland911/favorites" /> 
let $feed := http:send-request($req,())[2]/a:feed 
for $entry in $feed/a:entry 
return <h1>{$entry/a:title/text()}</h1> 

당신은 다음 예는 XQuery를 PHP 확장을 설치하는 방법에 대한 http://www.zorba-xquery.com/html/demo#ZOFhRE4SYzli8jy+39WJyegnhy4= 의 지시에 살고 시도 할 수는 http://www.zorba-xquery.com/html/entry/2011/12/27/PHP_Meets_XQuery

에서 구할 수 있습니다
+0

감사합니다. 작동하지만 위에 게시 할 다른 솔루션을 찾았습니다. – user804736