|
Jereme Hancock - 2009-01-27 17:57:53
Love this class!!
How can I add two more fields to the example.php for the user to input their Youtube Username and Password?
Thanks, Jereme
Cesar D. Rodas - 2009-01-27 19:08:59 - In reply to message 1 from Jereme Hancock
Hello!
You should send the username and password through the same form, and change the example.php
define("YT_USER","user");
define("YT_PASS","pass");
for:
define("YT_USER",$_POST["user"]);
define("YT_PASS",$_POST["pass"]);
I assume that your field for username is called "user", and the password is "pass".
Then you should change:
alert("Unexpected error");
for:
alert("Bad username or password");
Regards
Jereme Hancock - 2009-01-27 20:34:33 - In reply to message 2 from Cesar D. Rodas
Thanks, but I could not get that to work.
This is what I have now and it seems to work. The only issue is I can't set the password field to be a password type.
<?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","####");
class preprocessing_youtube extends phpajax
{
var $inputs = array('title','desc','cat','keyword','user','pass');
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,"#",$user,$pass);
$e=$dtube->upload($title,$desc,$cat,$keyword,$user,$pass);
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;
$('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('user','pass','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</a>
</body>
</html>
|