IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Langage PHP Discussion :

Identification API Youtube


Sujet :

Langage PHP

  1. #1
    Nouveau Candidat au Club
    Profil pro
    Inscrit en
    Juillet 2010
    Messages
    6
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juillet 2010
    Messages : 6
    Points : 1
    Points
    1
    Par défaut Identification API Youtube
    Bonjour a tous, je suis un jeune développeur et j'ai grand besoin de votre expérience (j'arrête mon léchage )

    Je met actuellement en place pour mon entreprise une appli php capable d'upload et de gérer les vidéos d'un utilisateur unique Youtube. Un mini-youtube sans prétention avec gestion de groupe, chaine, communauté ect...

    Bref, tous les tutoriels et sample que j'ai pu trouver sur le net sont obsolète, y compris ceux de developpez.com (sauf grossière erreur de ma part :s ). A reculons j'ai été prendre l'info a sa source sur google, j'y ai trouvé une machine a gaz que j'ai toutes les peines du monde a comprendre.

    Re-bref quelques cafés plus tard, mon plus gros soucis et l'identification par id utilisateur. J'ai ma clé développeur, mon compte google affilié a un compte youtube et j'ai ce petit bout de code pour l'identification qui ne marche pas =>

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    POST /accounts/ClientLogin HTTP/1.0Content-type: application/x-www-form-urlencoded
    accountType=GOOGLE
    &Email=<login>
    &Passwd=<passwd>
    &service=youtube
    &source=<source>
    Dont je ne sait pas trop quoi faire... j'ai tenté de la faire passé comme entête avec header() et sa donne => Error 500 - Internal server error (avec les logins et pwd renseigné bien sur ^^)

    J'ai fais passé les paramètres en POST avec un formulaire et des champs input type=hidden (a la barbare) , sa me renvoie bien sur le serveur google avec mon tokken et mon id client, mais pas d'identification et de retour sur ma page d'origine...

    Une idée s'il vous plait? J'en suis a cour :s

  2. #2
    Membre émérite
    Avatar de supersnail
    Homme Profil pro
    Inscrit en
    Novembre 2006
    Messages
    1 719
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Novembre 2006
    Messages : 1 719
    Points : 2 793
    Points
    2 793
    Par défaut
    Bonjour,

    Tu pourrais nous montrer le code que tu as écrit? Ca nous serait utile
    Toute question technique envoyée en MP ira directement à la poubelle

    Un code ne marchera jamais, il n'a jamais reçu la capacité de se déplacer.
    Inutile donc de dire "ça marche pas", donnez plutôt des informations précises afin de mieux pouvoir vous aider.


    Grand gourou de la -attitude

  3. #3
    Nouveau Candidat au Club
    Profil pro
    Inscrit en
    Juillet 2010
    Messages
    6
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juillet 2010
    Messages : 6
    Points : 1
    Points
    1
    Par défaut
    L'index.php en entier, c'est l'exemple proposé par google, très complet. Mais impossible de m'identifier pour le moment


    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    <?php
     
     
     
     
    header("POST /accounts/ClientLogin HTTP/1.0");
    header("Content-type: application/x-www-form-urlencoded");
    header("accountType=GOOGLE&Email=<>&Passwd=<>69&service=youtube&source=<>");
     
     
    /**
     * Zend Framework
     *
     * LICENSE
     *
     * This source file is subject to the new BSD license that is bundled
     * with this package in the file LICENSE.txt.
     * It is also available through the world-wide-web at this URL:
     * http://framework.zend.com/license/new-bsd
     * If you did not receive a copy of the license and are unable to
     * obtain it through the world-wide-web, please send an email
     * to license@zend.com so we can send you a copy immediately.
     *
     * @category   Zend
     * @package    Zend_Gdata
     * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
     * @license    http://framework.zend.com/license/new-bsd     New BSD License
     */
     
    /**
     * PHP sample code for the YouTube data API.  Utilizes the Zend Framework
     * Zend_Gdata component to communicate with the YouTube data API.
     *
     * Requires the Zend Framework Zend_Gdata component and PHP >= 5.1.4
     * This sample is run from within a web browser.  These files are required:
     * session_details.php - a script to view log output and session variables
     * operations.php - the main logic, which interfaces with the YouTube API
     * index.php - the HTML to represent the web UI, contains some PHP
     * video_app.css - the CSS to define the interface style
     * video_app.js - the JavaScript used to provide the video list AJAX interface
     *
     * NOTE: If using in production, some additional precautions with regards
     * to filtering the input data should be used.  This code is designed only
     * for demonstration purposes.
     */
     
    session_start();
     
    $_SESSION['sessionToken'] = $_POST['Auth'];
     
    /**
     * Set your developer key here.
     *
     * NOTE: In a production application you may want to store this information in
     * an external file.
     */
    $_SESSION['developerKey'] = 'AI39si5n38AyOAAL34cW7JmctHk0EnIkhL0gclpUbp7sfZz31_CohBG2QfGeRhwd8ayx-skvnkOAcjQNvPgy9NoCPNU64np4yg';
     
    /**
     * Convert HTTP status into normal text.
     *
     * @param number $status HTTP status received after posting syndicated upload
     * @param string $code Alphanumeric description of error
     * @param string $videoId (optional) Video id received back to which the status
     *        code refers to
     */
    function uploadStatus($status, $code = null, $videoId = null)
    {
        switch ($status) {
            case $status < 400:
                echo  'T&eacute;l&eacute;chargement reussis ! (id: '. $videoId .
                      ') <a href="#" onclick=" ytVideoApp.checkUploadDetails(\''.
                      $videoId .'\'); ">(details)</a>';
                break;
            default:
                echo "Il sembles qu'il y ai eu une erreur: ". $code .
                     '<a href="#" onclick=" ytVideoApp.checkUploadDetails(\''.
                     $videoId . '\'); ">(check details)</a>';
        }
    }
     
    /**
     * Helper function to check whether a session token has been set
     *
     * @return boolean Returns true if a session token has been set
     */
    function authenticated()
    {
        if (isset($_SESSION['sessionToken'])) {
            return true;
        }
    }
     
    /**
     * Helper function to print a list of authenticated actions for a user.
     */
    function printAuthenticatedActions()
    {
        print <<<END
            <div id="actions"><h3>Authenticated Actions</h3>
            <ul>
            <li><a href="#" onclick="ytVideoApp.listVideos('search_owner', '', 1);
            return false;">retrouver mes videos</a></li>
            <li><a href="#" onclick="ytVideoApp.prepareUploadForm();
            return false;">telecharger une video</a><br />
            <div id="syndicatedUploadDiv"></div><div id="syndicatedUploadStatusDiv">
            </div></li>
            <li><a href="#" onclick="ytVideoApp.retrievePlaylists();
            return false;">gérer mes playlists</a><br /></li>
            </ul></div>
    END;
    }
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//FR"
            "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
    <head>
      <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
      <meta name="google-site-verification" content="IjZBF9BzdXwuk-jwXjcLX5O2WqwfMugpzkXTRegly6o" />
      <title></title>
      <link href="video_app.css" type="text/css" rel="stylesheet" />
      <script src="video_app.js" type="text/javascript"></script>
     
     
    </head>
     
    <body>
      <div id="main">
        <div id="titleBar">
          <h1><center>Handi - Tube</center></h1>
     
            <div id="searchBox">
            <form id="searchForm" onsubmit="ytVideoApp.listVideos(this.queryType.value, this.searchTerm.value, 1); return false;" action="javascript:void();" >
            <div id="searchBoxTop"><select name="queryType" onchange="ytVideoApp.queryTypeChanged(this.value, this.form.searchTerm);" >
              <option value="search_all" selected="selected">Toutes les Vid&eacute;os</option>
              <option value="search_top_rated">Top Vid&eacute;os</option>
              <option value="search_most_viewed">Vidéos les plus regard&eacute;es</option>
              <option value="search_recently_featured">Vid&eacute;os les plus r&eacute;centes</option>
              <option value="search_username">Vid&eacute;os d'un utilisateur sp&eacute;cifique</option>
              <?php
                    if (authenticated()) {
                        echo '<option value="search_owner">Afficher mes vid&eacute;os</option>';
                    }
              ?>
            </select></div>
            <div><input name="searchTerm" type="text" value="Sur YouTube" />
            <input type="submit" value="Go" /></div>
          </form>
        </div>
        <br />
     
        </div>
        <br />
        <!-- Authentication status -->
        <div id="authStatus">
        <?php
          if (authenticated()) {
              print <<<END
                   <br />
    END;
          } else {
              print <<<END
                        <div id="generateAuthSubLink">
    					<form action="https://www.google.com/youtube/accounts/ClientLogin" method="post">
    					<input name="Email" type="hidden" value="<>" />
    					<input name="Passwd" type="hidden" value="<>" />
    					<input name="service" type="hidden" value="youtube" />
    					<input name="source" type="hidden" value="<>" />
    					<input name="nextUrl" type="hidden" value="http://www.handivision.net" />
    					<input type="submit" value="Go" /></div>
    					</form>
                        </div>
    END;
        }
    	//old line150 => onclick="ytVideoApp.presentAuthLink();return false;"
        ?>
        </div>
        <!-- end Authentication status -->
        <br clear="all" />
        <?php
            // if $_GET['status'] is populated then we have a response
            // about a syndicated upload from YouTube's servers
            if (isset($_GET['status'])) {
                (isset($_GET['code']) ? $code = $_GET['code'] : $code = null);
                (isset($_GET['id']) ? $id = $_GET['id'] : $id = null);
                print '<div id="generalStatus">' .
                      uploadStatus($_GET['status'], $code, $id) .
                      '<div id="detailedUploadStatus"></div></div>';
             }
        ?>
        <!-- General status -->
        <?php
            if (authenticated()) {
                printAuthenticatedActions();
            }
        ?>
        <!-- end General status -->
        <br clear="all" />
        <div id="searchResults">
          <div id="searchResultsListColumn">
            <div id="searchResultsVideoList"></div>
            <div id="searchResultsNavigation">
              <form id="navigationForm" action="javascript:void();">
                <input type="button" id="previousPageButton" onclick="ytVideoApp.listVideos(ytVideoApp.previousQueryType, ytVideoApp.previousSearchTerm, ytVideoApp.previousPage);" value="Back" style="display: none;" />
                <input type="button" id="nextPageButton" onclick="ytVideoApp.listVideos(ytVideoApp.previousQueryType, ytVideoApp.previousSearchTerm, ytVideoApp.nextPage);" value="Next" style="display: none;" />
              </form>
            </div>
          </div>
        <div id="searchResultsVideoColumn">
          <div id="videoPlayer"></div>
        </div>
      </div>
    </div>
    </body>
    </html>

  4. #4
    Expert confirmé
    Avatar de Thes32
    Homme Profil pro
    Développeur PHP, .Net, T-SQL
    Inscrit en
    Décembre 2006
    Messages
    2 379
    Détails du profil
    Informations personnelles :
    Sexe : Homme

    Informations professionnelles :
    Activité : Développeur PHP, .Net, T-SQL

    Informations forums :
    Inscription : Décembre 2006
    Messages : 2 379
    Points : 4 853
    Points
    4 853
    Par défaut
    salut,
    as tu bien suivie la doc de zend ? http://framework.zend.com/manual/en/...a.youtube.html
    Développeur | Zend Certified Engineer

    Étapes Pour mieux se servir du forum:
    1. Commencez par lire les cours et tutoriels ;
    2. Faites une recherche;
    3. Faites un post si rien trouvé dans les deux étapes précédentes en respectant les règles;

    Nix>_Rien n'est plus pratique que la théorie

  5. #5
    Nouveau Candidat au Club
    Profil pro
    Inscrit en
    Juillet 2010
    Messages
    6
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juillet 2010
    Messages : 6
    Points : 1
    Points
    1
    Par défaut
    Hélas, pour la docs de Zend, pour l'authenfication le tuto me renvoit vers la docs google que j'ai déja suivit sans succès :s , donc une nouvelle impasse snif :s

    Ma source sur code.google =>http://code.google.com/intl/fr/apis/...Authentication

  6. #6
    Membre émérite
    Avatar de supersnail
    Homme Profil pro
    Inscrit en
    Novembre 2006
    Messages
    1 719
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Novembre 2006
    Messages : 1 719
    Points : 2 793
    Points
    2 793
    Par défaut
    Bonjour,

    Tu dois envoyer la requête POST de connexion aux serveurs de youtube.
    Tu peux par exemple utiliser les sockets (comme le fait cette fonction):
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    function postEnvoi($host,$url,$post_params,$return = false)
    {
        //$url = urlencode($url);
     
        $fd = fsockopen($host,80);
        $POST = "POST /$url HTTP/1.1\r\n"; 
        $POST .= "Host: $host\r\n"; 
        $POST .= "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; FunWebProducts; Hotbar 4.5.1.0)\r\n"; 
        $POST .= "Accept: */*\r\n"; 
        $POST .= "Connection: close\r\n"; 
        $POST .= "Content-Type: application/x-www-form-urlencoded\r\n"; 
        $POST .= "Content-length: ".strlen( $post_params )."\r\n";
        $POST .= "\r\n";
        $POST .= $post_params."\r\n";
     
        fputs($fd,$POST);
     
     
        $buf = "";
        if($return)
        {
     
            while (($line = fgets($fd)) != "")
            {
                $buf .= $line;
            }
     
        }
        fclose($fd);
        return $buf;
    }
    Toute question technique envoyée en MP ira directement à la poubelle

    Un code ne marchera jamais, il n'a jamais reçu la capacité de se déplacer.
    Inutile donc de dire "ça marche pas", donnez plutôt des informations précises afin de mieux pouvoir vous aider.


    Grand gourou de la -attitude

  7. #7
    Nouveau Candidat au Club
    Profil pro
    Inscrit en
    Juillet 2010
    Messages
    6
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juillet 2010
    Messages : 6
    Points : 1
    Points
    1
    Par défaut
    Edit : en relisant le tuto... un collègue ma fait remarquer que l'auth par login n'était pas ce qu'il me fallait pour mon appli web... Je reposterais sur le même sujet si j'ai un autre problème sur l'authentification.

  8. #8
    Nouveau Candidat au Club
    Profil pro
    Inscrit en
    Juillet 2010
    Messages
    6
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juillet 2010
    Messages : 6
    Points : 1
    Points
    1
    Par défaut
    Je n'ai toujours pas de solution. J'explique avec plus de précision mon cas.

    Mon appli php, je souhaiterais être connecté avec mon compte youtube dès qu'un utilisateur ouvre la page. (le token, la "clef d'authentification" va en variable de session et ensuite je suis tranquille)

    Comme cité plus haut, j'ai récupéré le script de test de connexion de google ou une authentification par AuthSub est utilisé. Elle fonctionne, mais malheureusement l'utilisateur doit s'authentifier sur youtube avec un compte et "Autoriser l'accès à votre compte" ( ==> Ce site Web ne s'est pas inscrit auprès de YouTube pour établir une connexion sécurisée lors de demandes d'autorisation. Nous vous recommandons de ne poursuivre ce traitement que si vous avez confiance dans la destination suivante : monsite.net)

    Donc voilà j'ai tous dis


  9. #9
    Nouveau Candidat au Club
    Profil pro
    Inscrit en
    Juillet 2010
    Messages
    6
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juillet 2010
    Messages : 6
    Points : 1
    Points
    1
    Par défaut
    Identification par un socket, echec. Bad authentification. L'api youtube exige une reponse sécurisé.

    Je suis a cours de piste et de solution.

Discussions similaires

  1. Réponses: 8
    Dernier message: 01/03/2013, 15h06
  2. Probleme avec la lecture du Flux Atom de l'API YouTube
    Par Hamtoto dans le forum Services Web
    Réponses: 2
    Dernier message: 06/07/2009, 10h09
  3. Problème d'intégration de l'API Youtube
    Par aloisio11 dans le forum Windows Forms
    Réponses: 0
    Dernier message: 12/06/2009, 10h13
  4. Implémentation de l'API Youtube
    Par floboss dans le forum Bibliothèques & Frameworks
    Réponses: 0
    Dernier message: 07/12/2008, 17h19

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo