Exemplo n.º 1
0
 /**
  * @param $to_user 普通用户openid
  * @param $media_id 媒体ID
  */
 public function __construct($to_user, $media_id)
 {
     parent::__construct($to_user);
     $this->params['msgtype'] = 'image';
     $this->params['image'] = [];
     $this->params['image']['media_id'] = $media_id;
 }
Exemplo n.º 2
0
 /**
  * @param $to_user 普通用户openid
  * @param $text 文本消息内容
  */
 public function __construct($to_user, $text)
 {
     parent::__construct($to_user);
     $this->params['msgtype'] = 'text';
     $this->params['text'] = [];
     $this->params['text']['content'] = $text;
 }
Exemplo n.º 3
0
 /**
  * @param $to_user 普通用户openid
  * @param $media_id 发送的语音的媒体ID
  */
 public function __construct($to_user, $media_id)
 {
     parent::__construct($to_user);
     $this->params['msgtype'] = 'voice';
     $this->params['voice'] = [];
     $this->params['voice']['content'] = $media_id;
 }
Exemplo n.º 4
0
 /**
  * Constructor.
  *
  * @param string $method        The HTTP verb
  * @param string $path          The resource path on the server
  * @param string $scheme        The protocole name (HTTP or HTTPS)
  * @param string $schemeVersion The scheme version (ie: 1.0, 1.1 or 2.0)
  * @param array  $headers       An associative array of headers
  * @param string $body          The request content
  */
 public function __construct($method, $path, $scheme, $schemeVersion, array $headers = array(), $body = '')
 {
     parent::__construct($scheme, $schemeVersion, $headers, $body);
     $this->setMethod($method);
     $this->path = $path;
     $this->attributes = [];
 }
Exemplo n.º 5
0
 /**
  * Constructor.
  *
  * @param string $method        The HTTP verb
  * @param string $path          The resource path on the server
  * @param string $scheme        The protocole name (HTTP or HTTPS)
  * @param string $schemeVersion The scheme version (ie: 1.0, 1.1 or 2.0)
  * @param array  $headers       An associative array of headers
  * @param string $body          The request content
  */
 public function __construct($method, $path, $scheme, $schemeVersion, array $headers = [], $body = '')
 {
     parent::__construct($scheme, $schemeVersion, $headers, $body);
     $this->attributes = [];
     $this->setMethod($method);
     $this->path = $path;
     $this->requestParameters = [];
     $this->cookieParameters = [];
     $this->queryParameters = [];
 }
Exemplo n.º 6
0
 /**
  * @param $to_user 普通用户openid
  * @param $media_id 发送的视频的媒体ID
  * @param $thumb_media_id 缩略图的媒体ID
  * @param null $title 视频消息的标题
  * @param null $description 视频消息的描述
  */
 public function __construct($to_user, $media_id, $thumb_media_id, $title = null, $description = null)
 {
     parent::__construct($to_user);
     $this->params['msgtype'] = 'video';
     $this->params['video'] = [];
     $this->params['video']['media_id'] = $media_id;
     $this->params['video']['thumb_media_id'] = $thumb_media_id;
     $this->params['video']['title'] = $title;
     $this->params['video']['description'] = $description;
 }
Exemplo n.º 7
0
 /**
  * @param $to_user 普通用户openid
  * @param NewsMessageItem[] $news_items
  */
 public function __construct($to_user, $news_items)
 {
     parent::__construct($to_user);
     $this->params['msgtype'] = 'news';
     $this->params['news'] = [];
     $this->params['news']['articles'] = [];
     foreach ($news_items as $item) {
         $this->params['news']['articles'][] = $item->getParams();
     }
 }
Exemplo n.º 8
0
 /**
  * @param $to_user 普通用户openid
  * @param $music_url 音乐链接
  * @param $hq_music_url 高品质音乐链接,wifi环境优先使用该链接播放音乐
  * @param $thumb_media_id 缩略图的媒体ID
  * @param null $title 音乐标题
  * @param null $description 音乐描述
  */
 public function __construct($to_user, $music_url, $hq_music_url, $thumb_media_id, $title = null, $description = null)
 {
     parent::__construct($to_user);
     $this->params['msgtype'] = 'music';
     $this->params['music'] = [];
     $this->params['music']['title'] = $title;
     $this->params['music']['description'] = $description;
     $this->params['music']['musicurl'] = $music_url;
     $this->params['music']['hqmusicurl'] = $hq_music_url;
     $this->params['music']['thumb_media_id'] = $thumb_media_id;
 }
Exemplo n.º 9
0
 public function __construct($statusCode, $scheme, $schemeVersion, array $headers, $body)
 {
     parent::__construct($scheme, $schemeVersion, $headers, $body);
     $this->setStatusCode($statusCode);
 }
Exemplo n.º 10
0
 /**
  * Request constructor.
  * @param string $method        The HTTP verb
  * @param string $path          The resource path on the server
  * @param string $scheme        The protocole name (HTTP or HTTPS)
  * @param string $schemeVersion The scheme version (ie: 1.0, 1.1, or 2.0)
  * @param array $headers        An associative array of headers
  * @param string $body          The request content
  */
 public function __construct($method, $path, $scheme, $schemeVersion, array $headers = [], $body = '')
 {
     parent::__construct($scheme, $schemeVersion, $headers, $body);
     $this->setMethod($method);
     $this->setPath($path);
 }
Exemplo n.º 11
0
 private function detectContentType()
 {
     if (!class_exists('finfo', false)) {
         return false;
     }
     $finfo = new \finfo(FILEINFO_MIME_TYPE);
     return $this->file ? $finfo->file($this->file) : $finfo->buffer(parent::getContent());
 }
Exemplo n.º 12
0
 private function detectContentType()
 {
     $finfo = new \finfo(FILEINFO_MIME_TYPE);
     return $this->file ? $finfo->file($this->file) : $finfo->buffer(parent::getContent());
 }
Exemplo n.º 13
0
 public function __construct($message, array $users = [])
 {
     parent::__construct($message);
     $this->facebookUsers = $users;
 }
Exemplo n.º 14
0
 /**
  * Get a query builder for events
  * @return QueryBuilder
  */
 public static function getQueryBuilder()
 {
     return parent::getQueryBuilder()->eventsOnly();
 }
Exemplo n.º 15
0
 /**
  * Returns a string representation of the current request.
  *
  * @return string
  */
 public function __toString()
 {
     $string = sprintf("%s %s HTTP/%.1f\r\n", $this->getMethod(), $this->getResource(), $this->getProtocolVersion());
     if ($host = $this->getHost()) {
         $string .= 'Host: ' . $host . "\r\n";
     }
     if ($parent = trim(parent::__toString())) {
         $string .= $parent . "\r\n";
     }
     return $string;
 }
Exemplo n.º 16
0
 public function sendMessage($msg, $user)
 {
     parent::sendMessage($msg, $user);
 }
Exemplo n.º 17
0
 /**
  * Constructor.
  *
  * @param array $content
  */
 public function __construct($content)
 {
     parent::__construct(['content' => strval($content)]);
 }
Exemplo n.º 18
0
 /**
  * Constructor.
  *
  * @param string $rawContent Original message as received from ami.
  *
  * @return void
  */
 public function __construct($rawContent)
 {
     parent::__construct();
     $this->channelVariables = array('default' => array());
     $this->rawContent = $rawContent;
     $lines = explode(Message::EOL, $rawContent);
     foreach ($lines as $line) {
         $content = explode(':', $line);
         $name = strtolower(trim($content[0]));
         unset($content[0]);
         $value = isset($content[1]) ? trim(implode(':', $content)) : '';
         if (!strncmp($name, 'chanvariable', 12)) {
             // https://github.com/marcelog/PAMI/issues/85
             $matches = preg_match("/\\(([^\\)]*)\\)/", $name, $captures);
             $chanName = 'default';
             if ($matches > 0) {
                 $chanName = $captures[1];
             }
             $content = explode('=', $value);
             $name = strtolower(trim($content[0]));
             unset($content[0]);
             $value = isset($content[1]) ? trim(implode(':', $content)) : '';
             $this->channelVariables[$chanName][$name] = $value;
         } else {
             $this->setKey($name, $value);
         }
     }
     // https://github.com/marcelog/PAMI/issues/85
     if (isset($this->keys['channel'])) {
         $channel = strtolower($this->keys['channel']);
         if (isset($this->channelVariables[$channel])) {
             $this->channelVariables[$channel] = array_merge($this->channelVariables[$channel], $this->channelVariables['default']);
         } else {
             $this->channelVariables[$channel] = $this->channelVariables['default'];
         }
         unset($this->channelVariables['default']);
     }
 }
Exemplo n.º 19
0
 /**
  * Returns a string representation of the current request.
  * 
  * @return string
  */
 public function __toString()
 {
     return implode(PHP_EOL, array(sprintf('%s %s HTTP/%.1f', $this->getMethod(), $this->getResource(), $this->getProtocolVersion()), 'Host: ' . $this->getHost())) . PHP_EOL . parent::__toString();
 }
Exemplo n.º 20
0
 /**
  * {@inheritdoc}
  */
 public function withoutHeader(string $name) : Message
 {
     $new = parent::withoutHeader($name);
     if ('set-cookie' === strtolower($name)) {
         $new->cookies = [];
     }
     return $new;
 }
Exemplo n.º 21
0
 /**
  * Constructor.
  *
  * @param string $protocolVersion The protocol version.
  * @param int $statusCode The status code.
  * @param string $reasonPhrase The reason phrase.
  * @param string[][] $headers The headers.
  * @param StreamInterface $body The body.
  */
 public function __construct($protocolVersion = self::DEFAULT_PROTOCOL_VERSION, $statusCode = StatusCode::OK, $reasonPhrase = '', array $headers = [], StreamInterface $body = null)
 {
     parent::__construct($protocolVersion, $headers, $body);
     $this->statusCode = $statusCode;
     $this->reasonPhrase = $reasonPhrase === '' ? StatusCode::$reasonPhrase[$statusCode] : $reasonPhrase;
 }
Exemplo n.º 22
0
 /**
  * @param $method
  * @param $path
  * @param $scheme
  * @param $schemeVersion
  * @param array $headers
  * @param $body
  */
 public function __construct(string $method, string $path, string $scheme, string $schemeVersion, array $headers = [], string $body = '')
 {
     $this->path = $path;
     $this->setMethod($method);
     parent::__construct($scheme, $schemeVersion, $headers, $body);
 }
Exemplo n.º 23
0
 public function sendMessage($msg, $user)
 {
     $msg = "紧急信息:" . $msg;
     parent::sendMessage($msg, $user);
 }
Exemplo n.º 24
0
 /**
  * Sets the host based on the current URI.
  */
 private function setHostFromUri()
 {
     $this->hostFromUri = true;
     $host = $this->uri->getHost();
     if (!empty($host)) {
         // Do not set Host header if URI has no host.
         $port = $this->uri->getPort();
         if (null !== $port) {
             $host = sprintf('%s:%d', $host, $port);
         }
         parent::setHeader('Host', $host);
     }
 }
Exemplo n.º 25
0
 public function __construct($objectName = null)
 {
     parent::__construct('Message');
 }
Exemplo n.º 26
0
 public function addHeaders(array $headers)
 {
     parent::addHeaders($headers);
     $this->resetStatusLine();
 }
 public function testCanSetCustomHeaderFactory()
 {
     $f = new Header\HeaderFactory();
     $this->mock->setHeaderFactory($f);
     $this->assertSame($f, $this->readAttribute($this->mock, 'headerFactory'));
 }