/**
  * Creates individual Entry objects of the appropriate type and
  * stores them in the $_entry array based upon DOM data.
  *
  * @param DOMNode $child The DOMNode to process
  */
 protected function takeChildFromDOM($child)
 {
     $absoluteNodeName = $child->namespaceURI . ':' . $child->localName;
     switch ($absoluteNodeName) {
         case $this->lookupNamespace('yt') . ':' . 'position':
             $position = new Extension\Position();
             $position->transferFromDOM($child);
             $this->_position = $position;
             break;
         default:
             parent::takeChildFromDOM($child);
             break;
     }
 }
Example #2
0
 public function testEmptyVideoEntryToAndFromStringShouldMatch()
 {
     $entryXml = $this->entry->saveXML();
     $newVideoEntry = new YouTube\VideoEntry();
     $newVideoEntry->transferFromXML($entryXml);
     $newVideoEntryXml = $newVideoEntry->saveXML();
     $this->assertTrue($entryXml == $newVideoEntryXml);
 }
Example #3
0
 /**
  * Send a video message.
  *
  * Note: Either a ZendGData\YouTube\VideoEntry or a valid video ID must
  * be provided.
  *
  * @param string $body The body of the message
  * @param YouTube\VideoEntry $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 \ZendGData\App\InvalidArgumentException if no valid
  *         ZendGData\YouTube\VideoEntry or videoId were provided
  * @return \ZendGData\YouTube\InboxEntry|null The
  *         ZendGData\YouTube\InboxEntry representing the sent message.
  *
  */
 public function sendVideoMessage($body, $videoEntry = null, $videoId = null, $recipientUserName)
 {
     if (!$videoId && !$videoEntry) {
         throw new App\InvalidArgumentException('Expecting either a valid videoID or a videoEntry object in ' . '\\ZendGData\\YouTube->sendVideoMessage().');
     }
     $messageEntry = new 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->setSummary(new App\Extension\Summary($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, '\\ZendGData\\YouTube\\InboxEntry');
     return $response;
 }