<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); 
 class Youtube extends CI_Controller { 
	public function __construct() {  
               parent::__construct();
 	        $this->load->library('session');
                $this->load->helper('url');
		$this->load->library('zend');
		$this->zend->load('Zend/Loader');
		$this->load->model('commonmodel');
                $this->load->model('usersmodel');

		Zend_Loader::loadClass('Zend_Gdata_AuthSub');
		Zend_Loader::loadClass('Zend_Gdata_YouTube'); 
		Zend_Loader::loadClass('Zend_Uri_Http');
    }

    public function index(){

		if (!isset($_SESSION['sessionTokenYoutube']) && !isset($_GET['token']) ){
			echo $httpClient = $this->getAuthSubHttpClient();
			redirect($httpClient);
			exit;
		}else {
			$httpClient = $this->getAuthSubHttpClient();
		}
		#--->>set authentication variable
		 	$applicationId = $this->config->item('youtube_google_appid');
			$clientId	   = $this->config->item('youtube_google_appsecret');
			$developerKey  = $this->config->item('youtube_developer_key');

			$yt = new Zend_Gdata_YouTube($httpClient,
	                             $applicationId,
	                             $clientId,
	                             $developerKey);

		#--->>get username

			echo "username:-".$getUserProfile = $yt->getUserProfile('default')->getUsername();
			echo "<br/>";

		#---->>Get user uploaded video

			$videoFeed = $yt->getUserUploads('default');
               try {
                 $videoFeed = $yt->getUserUploads('default');
                }                catch (Zend_Gdata_App_Exception $e)
                 {
                      print 'ERROR - Could not retrieve users video feed: '. $e->getMessage();
                  }
Advertisements