Skip to content

Commit

Permalink
Added a contructor to the controller for loading the session library.…
Browse files Browse the repository at this point in the history
… Also added a method to perform a direct upload.
  • Loading branch information
Jim committed Sep 9, 2011
1 parent 36db005 commit 1e14b42
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions controllers/example.php
Expand Up @@ -2,6 +2,11 @@

class Example extends CI_Controller
{
public function __construct()
{
$this->load->library('session');
}

//CALL THIS METHOD FIRST BY GOING TO
//www.your_url.com/index.php/request_youtube
public function request_youtube()
Expand Down Expand Up @@ -56,6 +61,23 @@ public function youtube_auth()
$this->load->library('youtube', $params);
echo $this->youtube->getUserUploads();
}

public function direct_upload()
{
$videoPath = 'THE RELATIVE PATH ON YOUR SERVER TO THE VIDEO';
$videoType = 'THE CONTENT TYPE OF THE VIDEO'; //This is the mime type of the video ex: 'video/3gpp'

$params['apikey'] = 'ENTER YOUR GOOGLE YOUTUBE API KEY';
$params['oauth']['key'] = 'ENTER YOUR GOOGLE CONSUMER KEY';
$params['oauth']['secret'] = 'ENTER YOUR GOOGLE CONSUMER SECRET';
$params['oauth']['algorithm'] = 'HMAC-SHA1';
$params['oauth']['access_token'] = array('oauth_token'=>urlencode($this->session->userdata('oauth_token')),
'oauth_token_secret'=>urlencode($this->session->userdata('oauth_token_secret')));
$this->load->library('youtube', $params);

$metadata = '<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">Test Direct Upload</media:title><media:description type="plain">Test Direct Uploading.</media:description><media:category scheme="http://gdata.youtube.com/schemas/2007/categories.cat">People</media:category><media:keywords>test</media:keywords></media:group></entry>';
echo $this->youtube->directUpload($videoPath, $videoType, $metadata);
}
}

/* End of file example.php */
Expand Down

0 comments on commit 1e14b42

Please sign in to comment.