CodeIgniter Forums
How to solve my “HTTP method GET is not supported by this URL Error 405” with the YouTube API (upload)? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forum-22.html)
+--- Thread: How to solve my “HTTP method GET is not supported by this URL Error 405” with the YouTube API (upload)? (/thread-47573.html)



How to solve my “HTTP method GET is not supported by this URL Error 405” with the YouTube API (upload)? - El Forum - 12-14-2011

[eluser]DocFunky![/eluser]
Bonjour !

I'd like to know what can I do to solve my problem with the Youtube Upload Request. Each time I try to send a video, I get the follwing error message :

HTTP method GET is not supported by this URL

Error 405

And i've try some try / catch exception as I found some already existing similar problem, but nothing of what I found worked with me Sad

Could anyone help me please ?

Here is my function :
Code:
public function youtube_auth(){

   /* ********************************************************************************
    *                         Les inclusions de script
    * ********************************************************************************/

        set_include_path(get_include_path().PATH_SEPARATOR.FCPATH.'/application/libraries');

        require_once 'Zend/Loader.php';
        Zend_Loader::loadClass('Zend_Gdata_YouTube');
        $yt = new Zend_Gdata_YouTube();  

        require_once 'Zend/Gdata/YouTube.php';
        require_once 'Zend/Gdata/ClientLogin.php';

   /* ********************************************************************************
    *                         ETAPE 1 => Authentification
    * ********************************************************************************/    

        // configuration et identifiants

        $authenticationURL = 'https://www.google.com/youtube/accounts/ClientLogin'; // Url pour s'identifier
        $developerKey = 'VALID-KEY-HERE'; // Clé développeur
        $applicationId = 'ytapi-SocialPlatform'; // Identifiant de l'application
        $clientId = NULL; // Identifiant Client
        $username = "[email protected]"; // Login/adresse mail de votre compte YouTube
        $password = "my-password"; // Mot de passe de votre compte YouTube

        // authentification via la méthode HTTP

        $httpClient = Zend_Gdata_ClientLogin::getHttpClient(
            $username,$password,'youtube',null,'MonSiteWeb',null,null,$authenticationURL
        );
        $yt = new Zend_Gdata_YouTube($httpClient, $applicationId, $clientId, $developerKey);

   /* ********************************************************************************
    *                         ETAPE 2 => Envoie des d'Informations sur la vidéo
    * ********************************************************************************/


        // création d'un nouvel objet video

        $myVideoEntry = new Zend_Gdata_YouTube_VideoEntry();

        // on donne des informations sur notre vidéo

        $myVideoEntry->setVideoTitle('Test1');
        $myVideoEntry->setVideoDescription('Bah c est un test quoi !');
        $myVideoEntry->setVideoCategory('Sports'); // La catégorie doit correspondre à une catégorie YouTube
        $myVideoEntry->SetVideoTags('test, essai');
        $myVideoEntry->SetVideoDeveloperTags(array('mydevtag','anotherdevtag'));

   /* ********************************************************************************
    *                         ETAPE 3 => Récupération du Token unique
    * ********************************************************************************/

        // Récupération du token

        $tokenHandlerUrl = 'http://gdata.youtube.com/action/GetUploadToken';
        try{
            $tokenArray = $yt->getFormUploadToken($myVideoEntry, $tokenHandlerUrl);
        }
        catch ( Zend_Gdata_HttpException $e ){
            print "Error ZendGdataException";
        }
        $tokenValue = $tokenArray['token'];
        $postUrl = $tokenArray['url'];


    /* ********************************************************************************
    *                         ETAPE 4 => Envoie de la vidéo
    * ********************************************************************************/    

        // Page sur laquelle sera renvoyé l'utilisateur après la validation
        // du formulaire (URL de retour)

        $nextUrl = 'http://s390075769.onlinehome.fr/index.php?/site/';

        // Affichage du formulaire

        $form = '<form action="'. htmlspecialchars($postUrl, ENT_QUOTES) .'?nexturl='
        . urlencode($nextUrl) . ' method="post" enctype="multipart/formdata">
        Fichier vidéo : <input name="file" type="file"/>
        <input name="token" type="hidden" value="'. $tokenValue .'"/>
        <input value="Envoyer la vidéo" type="submit" />
        </form>';

        echo $form;

    }

Thanks, if you need the youtube_retour function, just tell me.