http_Client = Zend_Gdata_ClientLogin::getHttpClient($this->youtube_username, $this->youtube_password, $this->youtube_service, null, $this->youtube_source, null, null, $this->authentication_URL); //--- End Create the http client string --- //--- Create the youtube stream ---- $this->youtube_stream = new Zend_Gdata_YouTube($this->http_Client, $this->application_Id, $this->client_Id, $this->developer_Key); //--- End Create the youtube stream ---- $video_entry = new Zend_Gdata_YouTube_VideoEntry(); // create a new Zend_Gdata_App_MediaFileSource object $filesource = $this->youtube_stream->newMediaFileSource($source_path.$source_file); $filesource->setContentType('video/avi'); //quicktime // set slug header $filesource->setSlug($source_file); // add the filesource to the video entry $video_entry->setMediaSource($filesource); //$video_title = substr($source_file, 0, strrpos($source_file, '.')); //--- Set video Title --- $video_entry->setVideoTitle($video_title); //$video_description = $video_title; //--- Set video Description --- $video_entry->setVideoDescription($video_description); // The category must be a valid YouTube category! //--- Set the video Category --- $video_entry->setVideoCategory($video_category); //$video_category = 'Comedy'; // Set keywords. Please note that this must be a comma-separated string // and that individual keywords cannot contain whitespace $video_entry->SetVideoTags($video_tags); //$video_tags = 'comedy,funny'; // set some developer tags -- this is optional // (see Searching by Developer Tags for more details) //$myVideoEntry->setVideoDeveloperTags(array('mydevtag', 'anotherdevtag')); // set the video's location -- this is also optional //--- Set the location --- if($lat != "" && $long != ""){ $this->youtube_stream->registerPackage('Zend_Gdata_Geo'); $this->youtube_stream->registerPackage('Zend_Gdata_Geo_Extension'); $where = $this->youtube_stream->newGeoRssWhere(); $position = $this->youtube_stream->newGmlPos($lat.' '.$long); //37.0 -122.0 $where->point = $this->youtube_stream->newGmlPoint($position); $video_entry->setWhere($where); } //--- End Set the location --- // try to upload the video, catching a Zend_Gdata_App_HttpException, // if available, or just a regular Zend_Gdata_App_Exception otherwise try { //--- upload video into youtube server --- $new_video_entry = $this->youtube_stream->insertEntry($video_entry, $this->upload_URL, 'Zend_Gdata_YouTube_VideoEntry'); // upload URI for the currently authenticated user return $new_video_entry; }catch (Zend_Gdata_App_HttpException $httpException) { return $httpException->getRawResponseBody(); }catch (Zend_Gdata_App_Exception $e) { return $e->getMessage(); } } //---- End Upload youtube --- //---- Delete youtube --- function delete_youtube($video_id){ //--- Create the http client string --- $this->http_Client = Zend_Gdata_ClientLogin::getHttpClient($this->youtube_username, $this->youtube_password, $this->youtube_service, null, $this->youtube_source, null, null, $this->authentication_URL); //--- End Create the http client string --- //--- Create the youtube stream ---- $this->youtube_stream = new Zend_Gdata_YouTube($this->http_Client, $this->application_Id, $this->client_Id, $this->developer_Key); //--- End Create the youtube stream ---- $video_entry = $this->youtube_stream->getVideoEntry($video_id, null, true); // true -> express can read, write and delete //if ($video_entry->getEditLink() != null) { $this->youtube_stream->delete($video_entry); return true; //}else{ // $this->youtube_stream->delete($video_entry); // return true; //} } //---- End Delete youtube --- //--- Get all video entry information --- function get_video_entry_info($video_entry) { $all_video_entry_info = array(); $all_video_entry_info["video_id"] = $video_entry->getVideoId(); $all_video_entry_info["flash_player_url"] = $video_entry->getFlashPlayerUrl(); return $all_video_entry_info; } //--- End Get all video entry information --- //--- Get this user all video --- function get_user_uploads_info($youtube_username){ //--- Create the http client string --- $this->http_Client = Zend_Gdata_ClientLogin::getHttpClient($this->youtube_username, $this->youtube_password, $this->youtube_service, null, $this->youtube_source, null, null, $this->authentication_URL); //--- End Create the http client string --- //--- Create the youtube stream ---- $this->youtube_stream = new Zend_Gdata_YouTube($this->http_Client, $this->application_Id, $this->client_Id, $this->developer_Key); //--- End Create the youtube stream ---- $this->youtube_stream->setMajorProtocolVersion(2); $all_video_feed = $this->youtube_stream->getuserUploads($youtube_username); return $all_video_feed; } //--- End Get this user all video --- //--- All Set information --- function set_youtube_username($youtube_username){ $this->youtube_username = $youtube_username; // youtube username } function set_youtube_password($youtube_password){ $this->youtube_password = $youtube_password; // youtube password } function set_authentication_URL($authentication_URL){ $this->authentication_URL = $authentication_URL; } function set_upload_URL($upload_URL){ $this->upload_URL = $upload_URL; } function set_developer_Key($developer_Key){ $this->developer_Key = $developer_Key; } function set_application_Id($application_Id){ $this->application_Id = $application_Id; //"Video uploader v1"; } function set_client_Id($client_Id){ $this->client_Id = $client_Id; //"My video upload client - v1"; } function set_youtube_service($youtube_service){ $this->youtube_service = $youtube_service; //"My video upload client - v1"; } function set_youtube_source($youtube_source){ $this->youtube_source = $youtube_source; //"My video upload client - v1"; } //--- End All Set information --- } ?>