예제 #1
0
 /**
  * Append parameters to HTTP request
  * @param HttpRequest $HttpRequest HTTP request instance
  */
 private function appendParameters(HttpRequest $HttpRequest)
 {
     switch ($HttpRequest->getMethod()) {
         case HttpRequest::METHOD_GET:
             foreach ($this->parameters as $field => $value) {
                 $HttpRequest->addGetField($field, $value);
             }
             break;
         case HttpRequest::METHOD_POST:
             $HttpRequest->setPostData($this->parameters);
             break;
     }
 }
예제 #2
0
 /**
  * Create request for method call
  * @param string $methodName API method name
  * @param array $parameters method call parameters
  * @return Request request object
  */
 private function getRequest($methodName, array $parameters = [])
 {
     $Request = new Request();
     $Request->setTransport(Request::TRANSPORT_CURL);
     $Request->setUrl(self::ENDPOINT_URI)->setConnectTimeout($this->getConnectTimeout())->setTimeout($this->getRequestTimeout())->addUrlField(sprintf('bot%s', $this->token), $methodName);
     if (!empty($parameters)) {
         $Request->setPostData($parameters);
     }
     return $Request;
 }
예제 #3
0
 /**
  * Create request method
  * @param Message $Message message instance
  * @return Request HTTP request instance
  */
 private function createRequest(Message $Message)
 {
     $Request = new Request();
     $Request->setTransport(Request::TRANSPORT_CURL);
     $Request->setUrl(self::ENDPOINT_URI)->setContentTypeCode(Request::CONTENT_TYPE_TEXT)->setConnectTimeout($this->getConnectTimeout())->setTimeout($this->getRequestTimeout());
     $data = array_merge(['user='******'from=' . $this->from, 'sign=' . $this->sign($Message)], $Message->export());
     $Request->setPostData(implode('&', $data));
     return $Request;
 }