/** * Creates a new YouTube instance * * @return void */ public function __construct() { include_once 'GoogleSDK/src/Google/autoload.php'; $this->_appId = 'Helioviewer.org User Video Uploader'; $this->_clientId = 'Helioviewer.org (2.4.0)'; //$this->_testURL = 'http://gdata.youtube.com/feeds/api/users/default/uploads?max-results=1'; //$this->_uploadURL = 'http://uploads.gdata.youtube.com/feeds/api/users/default/uploads'; if (!isset($_SESSION)) { # Note: If same user begins upload, and then shortly after tried # to upload a video again, PHP may hang when attempting to call # session_start(). May need a better way to make sure nothing else # is going on? (e.g. check for video entry in YouTube) session_start(); } $this->_httpClient = new Google_Client(); $this->_httpClient->setApplicationName("Helioviewer"); $this->_httpClient->setClientId(HV_GOOGLE_OAUTH2_CLIENT_ID); $this->_httpClient->setClientSecret(HV_GOOGLE_OAUTH2_CLIENT_SECRET); $this->_httpClient->setScopes('https://www.googleapis.com/auth/youtube.upload'); // Post-auth upload URL $redirect = filter_var(HV_WEB_ROOT_URL . '?action=uploadMovieToYouTube&html=true', FILTER_SANITIZE_URL); $this->_httpClient->setRedirectUri($redirect); //set proxy config for curl io if (!empty(HV_PROXY_HOST)) { $io = new Google_IO_Curl($this->_httpClient); $curloptions = array(); $curloptions[CURLOPT_PROXY] = HV_PROXY_HOST; if (!empty(HV_PROXY_USER_PASSWORD)) { $curloptions[CURLOPT_PROXYUSERPWD] = HV_PROXY_USER_PASSWORD; } $io->setOptions($curloptions); $this->_httpClient->setIo($io); } }