当前位置: 首页>>代码示例>>PHP>>正文


PHP createVideoIcon函数代码示例

本文整理汇总了PHP中createVideoIcon函数的典型用法代码示例。如果您正苦于以下问题:PHP createVideoIcon函数的具体用法?PHP createVideoIcon怎么用?PHP createVideoIcon使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了createVideoIcon函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: processUploadResponse

 /**
  * Process media upload response
  *
  * @param ProtocolNode $node
  *  Message node
  * @return bool
  */
 protected function processUploadResponse($node)
 {
     $id = $node->getAttribute("id");
     $messageNode = @$this->mediaQueue[$id];
     if ($messageNode == null) {
         //message not found, can't send!
         $this->eventManager()->fireMediaUploadFailed($this->phoneNumber, $id, $node, $messageNode, "Message node not found in queue");
         return false;
     }
     $duplicate = $node->getChild("duplicate");
     if ($duplicate != null) {
         //file already on whatsapp servers
         $url = $duplicate->getAttribute("url");
         $filesize = $duplicate->getAttribute("size");
         //            $mimetype = $duplicate->getAttribute("mimetype");
         $filehash = $duplicate->getAttribute("filehash");
         $filetype = $duplicate->getAttribute("type");
         //            $width = $duplicate->getAttribute("width");
         //            $height = $duplicate->getAttribute("height");
         $exploded = explode("/", $url);
         $filename = array_pop($exploded);
     } else {
         //upload new file
         $json = WhatsMediaUploader::pushFile($node, $messageNode, $this->mediaFileInfo, $this->phoneNumber);
         if (!$json) {
             //failed upload
             $this->eventManager()->fireMediaUploadFailed($this->phoneNumber, $id, $node, $messageNode, "Failed to push file to server");
             return false;
         }
         $url = $json->url;
         $filesize = $json->size;
         //            $mimetype = $json->mimetype;
         $filehash = $json->filehash;
         $filetype = $json->type;
         //            $width = $json->width;
         //            $height = $json->height;
         $filename = $json->name;
     }
     $mediaAttribs = array();
     $mediaAttribs["xmlns"] = "urn:xmpp:whatsapp:mms";
     $mediaAttribs["type"] = $filetype;
     $mediaAttribs["url"] = $url;
     $mediaAttribs["file"] = $filename;
     $mediaAttribs["size"] = $filesize;
     $mediaAttribs["hash"] = $filehash;
     $filepath = $this->mediaQueue[$id]['filePath'];
     $to = $this->mediaQueue[$id]['to'];
     switch ($filetype) {
         case "image":
             $icon = createIcon($filepath);
             break;
         case "video":
             $icon = createVideoIcon($filepath);
             break;
         default:
             $icon = '';
             break;
     }
     $mediaNode = new ProtocolNode("media", $mediaAttribs, null, $icon);
     if (is_array($to)) {
         $this->sendBroadcast($to, $mediaNode, "media");
     } else {
         $this->sendMessageNode($to, $mediaNode);
     }
     $this->eventManager()->fireMediaMessageSent($this->phoneNumber, $to, $id, $filetype, $url, $filename, $filesize, $filehash, $icon);
     return true;
 }
开发者ID:micschk,项目名称:WhatsAPI,代码行数:74,代码来源:whatsprot.class.php

示例2: processUploadResponse

 /**
  * Process media upload response.
  *
  * @param ProtocolNode $node Message node
  *
  * @return bool
  */
 public function processUploadResponse($node)
 {
     $id = $node->getAttribute('id');
     $messageNode = @$this->mediaQueue[$id];
     if ($messageNode == null) {
         //message not found, can't send!
         $this->eventManager()->fire('onMediaUploadFailed', [$this->phoneNumber, $id, $node, $messageNode, 'Message node not found in queue']);
         return false;
     }
     $duplicate = $node->getChild('duplicate');
     if ($duplicate != null) {
         //file already on whatsapp servers
         $url = $duplicate->getAttribute('url');
         $filesize = $duplicate->getAttribute('size');
         //          $mimetype = $duplicate->getAttribute("mimetype");
         $filehash = $duplicate->getAttribute('filehash');
         $filetype = $duplicate->getAttribute('type');
         //          $width = $duplicate->getAttribute("width");
         //          $height = $duplicate->getAttribute("height");
         $exploded = explode('/', $url);
         $filename = array_pop($exploded);
     } else {
         //upload new file
         $json = WhatsMediaUploader::pushFile($node, $messageNode, $this->mediaFileInfo, $this->phoneNumber);
         if (!$json) {
             //failed upload
             $this->eventManager()->fire('onMediaUploadFailed', [$this->phoneNumber, $id, $node, $messageNode, 'Failed to push file to server']);
             return false;
         }
         $url = $json->url;
         $filesize = $json->size;
         //          $mimetype = $json->mimetype;
         $filehash = $json->filehash;
         $filetype = $json->type;
         //          $width = $json->width;
         //          $height = $json->height;
         $filename = $json->name;
     }
     $mediaAttribs = [];
     $mediaAttribs['type'] = $filetype;
     $mediaAttribs['url'] = $url;
     $mediaAttribs['encoding'] = 'raw';
     $mediaAttribs['file'] = $filename;
     $mediaAttribs['size'] = $filesize;
     if ($this->mediaQueue[$id]['caption'] != '') {
         $mediaAttribs['caption'] = $this->mediaQueue[$id]['caption'];
     }
     if ($this->voice == true) {
         $mediaAttribs['origin'] = 'live';
         $this->voice = false;
     }
     $filepath = $this->mediaQueue[$id]['filePath'];
     $to = $this->mediaQueue[$id]['to'];
     switch ($filetype) {
         case 'image':
             $caption = $this->mediaQueue[$id]['caption'];
             $icon = createIcon($filepath);
             break;
         case 'video':
             $caption = $this->mediaQueue[$id]['caption'];
             $icon = createVideoIcon($filepath);
             break;
         default:
             $caption = '';
             $icon = '';
             break;
     }
     //Retrieve Message ID
     $message_id = $messageNode['message_id'];
     $mediaNode = new ProtocolNode('media', $mediaAttribs, null, $icon);
     if (is_array($to)) {
         $this->sendBroadcast($to, $mediaNode, 'media');
     } else {
         $this->sendMessageNode($to, $mediaNode, $message_id);
     }
     $this->eventManager()->fire('onMediaMessageSent', [$this->phoneNumber, $to, $message_id, $filetype, $url, $filename, $filesize, $filehash, $caption, $icon]);
     return true;
 }
开发者ID:Veivan,项目名称:WABuh,代码行数:85,代码来源:whatsprot.class.php


注:本文中的createVideoIcon函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。