Jump to content

YouTube update video request help


bilalaslam

Recommended Posts

Hi,

 

Thanks in advance, I want to update youtube videos. here is my code. let me tell you firstly, i am very new to php.

 

public function updateVideo($title,$description)

{

$title="Hello";

$description="Updating video info";

$result=$this->clientLoginAuth($this->username,$this->pass);

//$fdata = file_get_contents($fullFilePath);

$tmpdata = '<?xml version="1.0"?>

<entry xmlns="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/" xmlns:yt="http://gdata.youtube.com/schemas/2007">

<media:group>

<media:title type="plain">'.$title.'</media:title>

<media:description type="plain">'.$description.'</media:description>

<media:category scheme="http://gdata.youtube.com/schemas/2007/categories.cat">People</media:category><media:keywords>Breathe Parkour Magazine</media:keywords>

</media:group>

<yt:accessControl action="comment" permission="allowed"/>

  <yt:accessControl action="commentVote" permission="allowed"/>

  <yt:accessControl action="videoRespond" permission="allowed"/>

  <yt:accessControl action="rate" permission="allowed"/>

  <yt:accessControl action="list" permission="allowed"/>

  <yt:accessControl action="embed" permission="allowed"/>

  <yt:accessControl action="syndicate" permission="allowed"/>

 

</entry>

';

$url = 'http://gdata.youtube.com/feeds/api/users/breathparkour/uploads/6yStkCdeLEU';

//echo $url;

$data = '--f93dcbA3

Content-Type: application/atom+xml; charset=UTF-8

 

'.$tmpdata.'

--f93dcbA3

Content-Type: video/quicktime';

 

//echo $data;

return $this->make_update_request($url,$data);

}

 

public function make_update_request($url,$data){

 

//echo $url;

 

$token = $this->accessToken;

$developerKey = $this->developerKey;

 

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $url);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

 

if($this->authType == 'GoogleLogin')

$curlheader[0] = "Authorization: ".$this->authType." auth=\"$token\"";

else

$curlheader[0] = "Authorization: ".$this->authType." token=\"$token\"";

 

$curlheader[1] = "X-GData-Key: key=\"$developerKey\"";

$curlheader[2] = "Host: gdata.youtube.com";

$curlheader[3] = "Content-Type: application/atom+xml";

$curlheader[4] = "Content-Length: ".strlen($data);

$curlheader[5] = "GData-Version: 2";

 

curl_setopt($ch, CURLOPT_HTTPHEADER, $curlheader);

//curl_setopt($ch, CURLOPT_POST, 1);

curl_setopt($ch, CURLOPT_POSTFIELDS, $data);

curl_setopt($ch, CURLOPT_PUT, true);

 

 

$output = curl_exec($ch);

curl_close($ch);

 

print_r($output);

 

$validresult = $this->checkErrors($output);

 

print_r($validresult);

 

//echo $output;

if($validresult['is_error'] == 'No')

{

unset($validresult);

return "Success";

}

else

{

$result = array();

$result['is_error'] = $validresult['is_error'];

$result['error'] = $validresult['error'];

unset($validresult);

return $result;

 

}

}

 

 

i am getting this error.

 

GDataParseExceptionPremature end of file

 

Please help me. i have spent almost 6 hours on this issue. Pleazzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz

 

Link to comment
https://forums.phpfreaks.com/topic/227186-youtube-update-video-request-help/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.