Jaxel |
01-02-2009 12:30 PM |
Okay... I'm having trouble getting some new data from the YouTube API... maybe someone can help me...
For adding new videos, I have two new fields - name/id = taglist (this is for adding tags)
- name/id = timelength (this is for video duration)
And this is my YouTube.XML prepare_data function as it stands right now:
Code:
function prepare_data()
{
if (!$this->verify_videoid())
{
return false;
}
//Request Video Data
$vurl = new vB_vURL($this->registry);
$vurl->set_option(VURL_URL, 'http://gdata.youtube.com/feeds/api/videos/' . $this->video_id);
$vurl->set_option(VURL_USERAGENT, 'vBulletin/' . FILE_VERSION . ' | Video Directory');
$vurl->set_option(VURL_RETURNTRANSFER, 1);
$vurl->set_option(VURL_TIMEOUT, 30);
$result = $vurl->exec();
if ($vurl->fetch_error())
{
$this->set_error(VSS_ERROR_CONNECTION);
return false;
}
require_once(DIR . '/includes/class_xml.php');
$xmlobj = new vB_XML_Parser($result);
if(!$arr = $xmlobj->parse())
{
$this->set_error(VSS_ERROR_RESPONSE);
return false;
}
if (isset($arr['yt:noembed']))
{
$this->set_error(VSS_ERROR_NOEMBEDING);
return false;
}
$this->thumbnailpath = $arr['media:group']['media:thumbnail'][0]['url'];
$this->videodescription = $arr['media:group']['media:description']['value'];
$this->videotitle = $arr['media:group']['media:title']['value'];
$this->taglist = $arr['media:group']['media:keywords']['value'];
$this->timelength = $arr['media:group']['yt:duration']['seconds'];
return true;
}
And this is my vbulletin_ajax_videodirectory.js AJAX code as it stands right now:
Code:
function request_videoinfo()
{
if (!fetch_object('videourl').value)
{
return false;
}
YAHOO.util.Connect.asyncRequest("POST", "video.php?do=videoinfo", {
success: handel_videoinfo,
failure: vBulletin_AJAX_Error_Handler,
timeout: 15000
}, SESSIONURL + 'securitytoken=' + SECURITYTOKEN + "&url=" + PHP.urlencode(fetch_object('videourl').value) + "&wysiwyg=" + vB_Editor[editor_id].wysiwyg_mode);
fetch_object('videoajaxbutton').value = vbphrase['requesting_information_please_wait'];
fetch_object('videoajaxbutton').disabled = true;
return false;
}
function handel_videoinfo(ajax)
{
if (ajax.responseXML)
{
// check for error first
var error = ajax.responseXML.getElementsByTagName('error');
if (error.length)
{
fetch_object('thumbnail').setAttribute('src', '');
fetch_object('thumbnail_border').style.display = 'none';
alert(error[0].firstChild.nodeValue);
}
else
{
try
{
var description = ajax.responseXML.getElementsByTagName('description')[0].firstChild.nodeValue;
vB_Editor[editor_id].insert_text(description);
}
catch (e)
{
}
try
{
var title = ajax.responseXML.getElementsByTagName('title')[0].firstChild.nodeValue;
fetch_object('videotitle').value = title;
}
catch (e)
{
}
try
{
var keywords = ajax.responseXML.getElementsByTagName('keywords')[0].firstChild.nodeValue;
fetch_object('taglist').value = keywords;
}
catch (e)
{
}
try
{
var duration = ajax.responseXML.getElementsByTagName('duration')[0].firstChild.nodeValue;
fetch_object('timelength').value = duration;
}
catch (e)
{
}
try
{
var videothumbnailpath = ajax.responseXML.getElementsByTagName('thumbnailpath')[0].firstChild.nodeValue;
fetch_object('thumbnail').setAttribute('src', videothumbnailpath);
fetch_object('thumbnail_border').style.display = '';
}
catch (e)
{
}
}
}
fetch_object('videoajaxbutton').value = vbphrase['request_videoinfo_from_service'];
fetch_object('videoajaxbutton').disabled = false;
}
Does anyone know why this isnt working? What am i missing?
|