示例#1
0
 /**
  * Send a video message.
  *
  * Note: Either a Zend_Gdata_YouTube_VideoEntry or a valid video ID must
  * be provided.
  *
  * @param string $body The body of the message
  * @param Zend_Gdata_YouTube_VideoEntry (optional) The video entry to send
  * @param string $videoId The id of the video to send
  * @param string $recipientUserName The username of the recipient
  * @throws Zend_Gdata_App_InvalidArgumentException if no valid
  *         Zend_Gdata_YouTube_VideoEntry or videoId were provided
  * @return Zend_Gdata_YouTube_InboxEntry|null The
  *         Zend_Gdata_YouTube_Inbox_Entry representing the sent message.
  *
  */
 public function sendVideoMessage($body, $videoEntry = null, $videoId = null, $recipientUserName)
 {
     if (!$videoId && !$videoEntry) {
         require_once 'Zend/Gdata/App/InvalidArgumentException.php';
         throw new Zend_Gdata_App_InvalidArgumentException('Expecting either a valid videoID or a videoEntry object in ' . 'Zend_Gdata_YouTube->sendVideoMessage().');
     }
     $messageEntry = new Zend_Gdata_YouTube_InboxEntry();
     if ($this->getMajorProtocolVersion() == null || $this->getMajorProtocolVersion() == 1) {
         if (!$videoId) {
             $videoId = $videoEntry->getVideoId();
         } elseif (strlen($videoId) < 12) {
             //Append the full URI
             $videoId = self::VIDEO_URI . '/' . $videoId;
         }
         $messageEntry->setId($this->newId($videoId));
         // TODO there seems to be a bug where v1 inbox entries dont
         // retain their description...
         $messageEntry->setDescription(new Zend_Gdata_YouTube_Extension_Description($body));
     } else {
         if (!$videoId) {
             $videoId = $videoEntry->getVideoId();
             $videoId = substr($videoId, strrpos($videoId, ':'));
         }
         $messageEntry->setId($this->newId($videoId));
         $messageEntry->setSummary($this->newSummary($body));
     }
     $insertUrl = 'https://gdata.youtube.com/feeds/api/users/' . $recipientUserName . '/inbox';
     $response = $this->insertEntry($messageEntry, $insertUrl, 'Zend_Gdata_YouTube_InboxEntry');
     return $response;
 }
 public function testConvertInboxEntryToAndFromString()
 {
     $this->entry->transferFromXML($this->entryText);
     $entryXml = $this->entry->saveXML();
     $newInboxEntry = new Zend_Gdata_YouTube_InboxEntry();
     $newInboxEntry->transferFromXML($entryXml);
     $this->verifyAllSamplePropertiesAreCorrect($newInboxEntry);
     $newInboxEntryXml = $newInboxEntry->saveXML();
     $this->assertEquals($entryXml, $newInboxEntryXml);
 }