PHP Classes

File: example.php

Recommend this page to a friend!
  Classes of Cesar D. Rodas   From Browser - Youtube Upload   example.php   Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Example using ajax
Class: From Browser - Youtube Upload
Upload videos to YouTube from another site forms
Author: By
Last change:
Date: 16 years ago
Size: 2,601 bytes
 

Contents

Class file image Download
<?php
error_reporting
(E_ALL);
include(
"btube.php");
require(
"phpajax/phpajax.php");

#take a look here
# http://code.google.com/apis/youtube/dashboard/
define("YT_KEY_DEV","xxxx");

define("YT_USER","user");
define("YT_PASS","pass");


class
preprocessing_youtube extends phpajax
{
    var
$inputs = array('title','desc','cat','keyword');
    var
$hotkeys="shift-u";
   
    function
loading()
    {
       
aprint('loading', 'Preprocessing...');
       
ashow('loading');
    }

    function
main()
    {
        global
$dbute;
        foreach (
$this as $k => $v)
            $
$k = & $this->$k;
       
$code=YT_KEY_DEV;
       
$dtube = new dtube($code,"http://cesar.la/",YT_USER,YT_PASS);
       
$e=$dtube->upload($title,$desc,$cat,$keyword);
        if (
$e == false)
        {
           
alert("Unexpected error");
            return;
        }
       
#here we need to submit our form
       
aprint("url",$e[0]);
       
#our token
       
aprint("token",$e[1]);
       
#trigger the upload
       
js("yt_do_upload();");
    }
}



/* Initiliaze php ajax*/
phpajax::init();

?>
<html>
<head>
    <title>Direct Youtube Upload</title>
<?php phpajax_js("phpajax/");?>
<script>
function $(name)
{
    return document.getElementById(name);
}

function yt_do_upload()
{
    //were go confirm the status? in nexturl
    $('form').action = $('url').value + "?nexturl=http://cesar.la/";
    $('form').submit();
    $('yt_frame').onload = yt_done;
    $('loading').innerHTML = "Uploading to youtube!...";
    setTimeout("ashow('loading');",3000);
}

function yt_done()
{
    alert("Upload done!");
    ahide("loading");
}
</script>
</head>
<body>
<div id='loading' style="visibility:hidden;">
Cargando...
</div>
<table>
    <?php foreach( array('title','desc','cat','keyword') as $id ): ?>
    <tr>
        <td><?php echo ucfirst($id)?>:</td>
        <td><input type="input" id="<?php echo $id?>" name="<?php echo $id?>"></td>
    </tr>
    <?php endforeach; ?>
<input type="input" id="url" style="display: none">
    <iframe name="yt_frame" id = "yt_frame" style="display: none" onload=""></iframe>
    <form action="" id="form" target="yt_frame" target method="post" enctype="multipart/form-data">
    <input type="input" id="token" name="token" style="display: none">
    <tr>
        <td>Video:</td>
        <td><input type="file" name="file1" id="file1"><td/>
    </tr>
</table>


   
   <a href="javascript:preprocessing_youtube()">Upload file (shift-u)</a>

</body>
</html>