Witam, chciałem zrobić upload filmu na youtube bezpośrednio z mojej strony.
Znalazłem klasę:
http://www.phpclasses.org/browse/package/4689.htmlmam cały czas błąd uploadu a formularz do wysyłania mam taki:
<?php
include("btube.php");
require("phpajax/phpajax.php");
#take a look here
# <a href=\"http://code.google.com/apis/youtube/dashboard/\" target=\"_blank\">http://code.google.com/apis/youtube/dashboard/</a>
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()
{
foreach ($this as $k => $v)
$$k = & $this->$k;
$code=YT_KEY_DEV;
$dtube = new dtube($code,"wp.pl",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><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="java script:preprocessing_youtube()">Upload file (shift-u)</a>
</body>
</html>
zawsze mam komunikat:
Unexpected error
Potrzebne dane podaje prawidłowe, generuje potrzebny key i nadal nic (IMG:
http://forum.php.pl/style_emoticons/default/sad.gif)