Pagina 1 di 2 1 2 ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 16
  1. #1
    Utente bannato
    Registrato dal
    Feb 2011
    Messaggi
    146

    [Estrarre video youtube]

    Come faccio ad estrarre tutti gli id dei video da questo xml
    http://gdata.youtube.com/feeds/api/v...results=10&v=2

    Codice PHP:
    <?php
    function download_page($path){
            
    $ch curl_init();
            
    curl_setopt($chCURLOPT_URL,$path);
            
    curl_setopt($chCURLOPT_FAILONERROR,1);
            
    curl_setopt($chCURLOPT_FOLLOWLOCATION,1);
            
    curl_setopt($chCURLOPT_RETURNTRANSFER,1);
            
    curl_setopt($chCURLOPT_TIMEOUT15);
            
    $retValue curl_exec($ch);                      
            
    curl_close($ch);
            return 
    $retValue;
    }
    $url='http://gdata.youtube.com/feeds/api/videos?q=football+-soccer&orderby=published&start-index=11&max-results=10&v=2';

    $sXML download_page(url);
    $oXML = new SimpleXMLElement($sXML);

    //da qui in poi non so che fare
    foreach($oXML->entry as $oEntry){
            echo 
    $oEntry->id "\n";
    }

  2. #2

    Re: [Estrarre video youtube]

    Sto scrivendo una classe per gestire i feed di youtube... grrrrrr (nn ho mai il tempo di finirla!!). Prova così:
    Codice PHP:
    <?php
    function download_page($path){
            
    $ch curl_init();
            
    curl_setopt($chCURLOPT_URL,$path);
            
    curl_setopt($chCURLOPT_FAILONERROR,1);
            
    curl_setopt($chCURLOPT_FOLLOWLOCATION,1);
            
    curl_setopt($chCURLOPT_RETURNTRANSFER,1);
            
    curl_setopt($chCURLOPT_TIMEOUT15);
            
    $retValue curl_exec($ch);                      
            
    curl_close($ch);
            return 
    $retValue;
    }
    $url='http://gdata.youtube.com/feeds/api/videos?q=football+-soccer&orderby=published&start-index=11&max-results=10&v=2';

    $sXML download_page(url);
    $oXML = new SimpleXMLElement($sXML);

    //da qui in poi non so che fare
    foreach($oXML->entry as $oEntry){
            
    $array_url = (string) explode('/'$oEntry->id);
        
    $id_video end($array_url);
        echo 
    $id_video;
    }
    http://www.miniscript.it
    Se ti sono stato di aiuto in qualche modo in questo forum iscriviti alla fan page di Miniscript - il mio blog di programmazione web.

  3. #3
    Utente bannato
    Registrato dal
    Feb 2011
    Messaggi
    146
    mi esce
    Warning: end() [function.end]: Passed variable is not an array or object in /homez.420/epicfailh/www/prova.php on line 21

    Warning: end() [function.end]: Passed variable is not an array or object in /homez.420/epicfailh/www/prova.php on line 21

    Warning: end() [function.end]: Passed variable is not an array or object in /homez.420/epicfailh/www/prova.php on line 21

    Warning: end() [function.end]: Passed variable is not an array or object in /homez.420/epicfailh/www/prova.php on line 21

    Warning: end() [function.end]: Passed variable is not an array or object in /homez.420/epicfailh/www/prova.php on line 21

    Warning: end() [function.end]: Passed variable is not an array or object in /homez.420/epicfailh/www/prova.php on line 21

    Warning: end() [function.end]: Passed variable is not an array or object in /homez.420/epicfailh/www/prova.php on line 21

    Warning: end() [function.end]: Passed variable is not an array or object in /homez.420/epicfailh/www/prova.php on line 21

    Warning: end() [function.end]: Passed variable is not an array or object in /homez.420/epicfailh/www/prova.php on line 21

    Warning: end() [function.end]: Passed variable is not an array or object in /homez.420/epicfailh/www/prova.php on line 21

  4. #4
    sono un deficiente (ho fatto un errore nel copia e incolla della mia classe):
    Codice PHP:
    foreach($oXML->entry as $oEntry){ 

        
    $id_video end(explode('/'$oEntry->id)); 
        echo 
    $id_video

    http://www.miniscript.it
    Se ti sono stato di aiuto in qualche modo in questo forum iscriviti alla fan page di Miniscript - il mio blog di programmazione web.

  5. #5
    Utente bannato
    Registrato dal
    Feb 2011
    Messaggi
    146
    no figurati grazie..

    Mi esce qualcosa in più del normale:
    tag:youtube.com,2008:video:iGVEoImXgfstag:youtube. com,2008:video:T07HUYK99Ystag:youtube.com,2008:vid eo:GRGij7DHzVAtag:youtube.com,2008:video:OSVVtYmGu 3wtag:youtube.com,2008:video:y2TMEbd0Isktag:youtub e.com,2008:video:vC-6XxorYzEtag:youtube.com,2008:video:SK_ISIQ8_RMtag: youtube.com,2008:video:FeFvkj-YXzctag:youtube.com,2008:videoYyvqCehWu4tag:youtube.com,2008:video:ndvGLWfQ0qI

  6. #6
    Utente bannato
    Registrato dal
    Feb 2011
    Messaggi
    146
    a me serve solo video:.......
    come faccio?

    grazie cmq per l'aiuto!

  7. #7
    metti un echo '
    '; nel ciclo così e aspè mo provo io da locale;

    Però fammi capire i feed che vuoi leggere: vuoi leggere i feed legati al canale di un utente o cosa?
    http://www.miniscript.it
    Se ti sono stato di aiuto in qualche modo in questo forum iscriviti alla fan page di Miniscript - il mio blog di programmazione web.

  8. #8
    Codice PHP:
    <?php
    function download_page($path){ 
            
    $ch curl_init(); 
            
    curl_setopt($chCURLOPT_URL,$path); 
            
    curl_setopt($chCURLOPT_FAILONERROR,1); 
            
    curl_setopt($chCURLOPT_FOLLOWLOCATION,1); 
            
    curl_setopt($chCURLOPT_RETURNTRANSFER,1); 
            
    curl_setopt($chCURLOPT_TIMEOUT15); 
            
    $retValue curl_exec($ch);                       
            
    curl_close($ch); 
            return 
    $retValue

    $url='http://gdata.youtube.com/feeds/api/videos?q=football+-soccer&orderby=published&start-index=11&max-results=10&v=2'

    $sXML download_page($url); 
    $oXML = new SimpleXMLElement($sXML); 
    //echo '<pre>';
    //da qui in poi non so che fare 
    foreach($oXML->entry as $oEntry){ 
        
    //var_dump($oEntry);
        
    $id_video end(explode(':'$oEntry->id)); 
        echo 
    $id_video
        echo 
    '
    '
    ;

    ?>
    Giusto per la cronaca:
    ma perchè non usi simplexml_load_file()?
    http://www.miniscript.it
    Se ti sono stato di aiuto in qualche modo in questo forum iscriviti alla fan page di Miniscript - il mio blog di programmazione web.

  9. #9
    Utente bannato
    Registrato dal
    Feb 2011
    Messaggi
    146
    praticamente ogni

    <id>tag:youtube.com,2008:video:JG2csRgFaRo</id>

    a me serve solo quello che viene dopo video:

    Codice PHP:
    <?php
    function download_page($path){
            
    $ch curl_init();
            
    curl_setopt($chCURLOPT_URL,$path);
            
    curl_setopt($chCURLOPT_FAILONERROR,1);
            
    curl_setopt($chCURLOPT_FOLLOWLOCATION,1);
            
    curl_setopt($chCURLOPT_RETURNTRANSFER,1);
            
    curl_setopt($chCURLOPT_TIMEOUT15);
            
    $retValue curl_exec($ch);
            
    curl_close($ch);
            return 
    $retValue;
    }
    $url='http://gdata.youtube.com/feeds/api/videos?q=football+-soccer&orderby=published&start-index=11&max-results=10&v=2';

    $sXML download_page($url);
    $oXML = new SimpleXMLElement($sXML);

    //da qui in poi non so che fare
    foreach($oXML->entry as $oEntry){
        
    $id_video end(explode('/'$oEntry->id));
        
    $title end(explode('/'$oEntry->title));

        echo 
    $id_video .'
    '
    ;
        echo 
    $title .'
    '
    ;
    }

    ?>

  10. #10
    Utente bannato
    Registrato dal
    Feb 2011
    Messaggi
    146
    AH OK GRAZIE COSI FUNZIONA BENE!

    GRAZIE!!

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.