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


PHP Request::post方法代码示例

本文整理汇总了PHP中Httpful\Request::post方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::post方法的具体用法?PHP Request::post怎么用?PHP Request::post使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Httpful\Request的用法示例。


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

示例1: RestClient

 /**
  * Interface for performing requests to PromisePay endpoints
  *
  * @param string $method required One of the four supported requests methods (get, post, delete, patch)
  * @param string $entity required Endpoint name
  * @param string $payload optional URL encoded data query
  * @param string $mime optional Set specific MIME type. Supported list can be seen here: http://phphttpclient.com/docs/class-Httpful.Mime.html
  */
 public static function RestClient($method, $entity, $payload = null, $mime = null)
 {
     // Check whether critical constants are defined.
     if (!defined(__NAMESPACE__ . '\\API_URL')) {
         die("Fatal error: API_URL constant missing. Check if environment has been set.");
     }
     if (!defined(__NAMESPACE__ . '\\API_LOGIN')) {
         die("Fatal error: API_LOGIN constant missing.");
     }
     if (!defined(__NAMESPACE__ . '\\API_PASSWORD')) {
         die("Fatal error: API_PASSWORD constant missing.");
     }
     if (!is_null($payload)) {
         if (is_array($payload) || is_object($payload)) {
             $payload = http_build_query($payload);
         }
         // if the payload isn't array or object, leave it intact
     }
     $url = constant(__NAMESPACE__ . '\\API_URL') . $entity . '?' . $payload;
     switch ($method) {
         case 'get':
             $response = Request::get($url)->authenticateWith(constant(__NAMESPACE__ . '\\API_LOGIN'), constant(__NAMESPACE__ . '\\API_PASSWORD'))->send();
             break;
         case 'post':
             $response = Request::post($url)->body($payload, $mime)->authenticateWith(constant(__NAMESPACE__ . '\\API_LOGIN'), constant(__NAMESPACE__ . '\\API_PASSWORD'))->send();
             break;
         case 'delete':
             $response = Request::delete($url)->authenticateWith(constant(__NAMESPACE__ . '\\API_LOGIN'), constant(__NAMESPACE__ . '\\API_PASSWORD'))->send();
             break;
         case 'patch':
             $response = Request::patch($url)->body($payload, $mime)->authenticateWith(constant(__NAMESPACE__ . '\\API_LOGIN'), constant(__NAMESPACE__ . '\\API_PASSWORD'))->send();
             break;
         default:
             throw new Exception\ApiUnsupportedRequestMethod("Unsupported request method {$method}.");
     }
     // check for errors
     if ($response->hasErrors()) {
         $errors = static::buildErrorMessage($response);
         switch ($response->code) {
             case 401:
                 throw new Exception\Unauthorized($errors);
                 break;
             case 404:
                 throw new Exception\NotFound($errors);
             default:
                 throw new Exception\Api($errors);
                 break;
         }
     }
     return $response;
 }
开发者ID:kublermdk,项目名称:promisepay-php,代码行数:59,代码来源:PromisePay.php

示例2: sendMessage

 /**
  * 根据详细参数发送企业消息
  * @Author   Woldy
  * @DateTime 2016-05-12T09:15:39+0800
  * @param    [type]                   $touser      [description]
  * @param    [type]                   $toparty     [description]
  * @param    [type]                   $content     [description]
  * @param    [type]                   $AgentID     [description]
  * @param    [type]                   $ACCESS_TOKEN [description]
  * @param    string                   $type        [description]
  * @return   [type]                                [description]
  */
 public static function sendMessage($touser, $toparty, $content, $AgentID, $ACCESS_TOKEN, $type = 'text')
 {
     //$content=iconv('GB2312', 'UTF-8', $content);
     //
     if ($type == 'text') {
         if (mb_detect_encoding($content, 'UTF-8') != 'UTF-8') {
             $content = iconv('GB2312', 'UTF-8', $content);
         }
         $param = array('touser' => $touser, 'toparty' => $toparty, 'agentid' => $AgentID, "msgtype" => "text", "text" => array("content" => $content));
         //var_dump(json_encode($param));
         //exit;
         $response = Request::post('https://oapi.dingtalk.com/message/send?access_token=' . $ACCESS_TOKEN)->body(json_encode($param))->sends('application/json')->send();
         if ($response->hasErrors()) {
             var_dump($response);
             exit;
         }
         if (!is_object($response->body)) {
             $response->body = json_decode($response->body);
         }
         if ($response->body->errcode != 0) {
             var_dump($response->body);
             exit;
         }
         echo 'send ok';
         exit;
     }
 }
开发者ID:woldy,项目名称:ddsdk,代码行数:39,代码来源:Message.php

示例3: createOrder

 /**
  * @param CreateOrderRequest $request
  * @return ApiError|CreateOrderResponse
  */
 public function createOrder(CreateOrderRequest $request)
 {
     $payload = array('merchantId' => $this->merchantId, 'apiId' => $this->apiId, 'orderId' => $request->getOrderId(), 'payCurrency' => $request->getPayCurrency(), 'payAmount' => $request->getPayAmount(), 'receiveAmount' => $request->getReceiveAmount(), 'description' => $request->getDescription(), 'culture' => $request->getCulture(), 'callbackUrl' => $request->getCallbackUrl(), 'successUrl' => $request->getSuccessUrl(), 'failureUrl' => $request->getFailureUrl());
     $formHandler = new \Httpful\Handlers\FormHandler();
     $data = $formHandler->serialize($payload);
     $signature = $this->generateSignature($data);
     $payload['sign'] = $signature;
     if (!$this->debug) {
         $response = \Httpful\Request::post($this->merchantApiUrl . '/createOrder', $payload, \Httpful\Mime::FORM)->expects(\Httpful\Mime::JSON)->send();
         if ($response != null) {
             $body = $response->body;
             if ($body != null) {
                 if (is_array($body) && count($body) > 0 && isset($body[0]->code)) {
                     return new ApiError($body[0]->code, $body[0]->message);
                 } else {
                     if (isset($body->depositAddress)) {
                         return new CreateOrderResponse($body->orderRequestId, $body->orderId, $body->depositAddress, $body->payAmount, $body->payCurrency, $body->receiveAmount, $body->receiveCurrency, $body->validUntil, $body->redirectUrl);
                     }
                 }
             }
         }
     } else {
         $response = \Httpful\Request::post($this->merchantApiUrl . '/createOrder', $payload, \Httpful\Mime::FORM)->send();
         exit('<pre>' . print_r($response, true) . '</pre>');
     }
 }
开发者ID:alcharkov,项目名称:spectrocoin-payment-gateway-for-woocommerce,代码行数:30,代码来源:SCMerchantClient.php

示例4: getHttpServer

 /**
  * @param Request $request
  *
  * @return HttpServer
  */
 public function getHttpServer(Request $request)
 {
     $url = $request->getUri();
     switch ($request->getMethod()) {
         case Request::METHOD_POST:
             $httpServer = HttpServer::post($url);
             break;
         case Request::METHOD_PUT:
             $httpServer = HttpServer::put($url);
             break;
         case Request::METHOD_DELETE:
             $httpServer = HttpServer::delete($url);
             break;
         default:
             $httpServer = HttpServer::get($url);
             break;
     }
     if ($request->headers) {
         $httpServer->addHeaders($request->headers->all());
     }
     if ($request->getUser()) {
         $httpServer->authenticateWith($request->getUser(), $request->getPassword());
     }
     if ($request->getContent()) {
         $httpServer->body($request->getContent());
     }
     return $httpServer;
 }
开发者ID:dongww,项目名称:web-monitor,代码行数:33,代码来源:Http.php

示例5: post

 public function post($endpoint, $data, $options = [])
 {
     $uri = Client::endpoint() . $endpoint . Client::getUriOptions($options);
     $data = json_encode($data);
     $response = \Httpful\Request::post($uri)->authenticateWith(Client::key(), Client::secret())->addHeaders(Client::headers())->body($data)->send();
     return $response;
 }
开发者ID:vicioux,项目名称:apisdk,代码行数:7,代码来源:client.php

示例6: sendRequest

 private function sendRequest($url, $data, array $options = null, $auth = null, $apiKey = null)
 {
     array_merge($this->_headers, $options);
     if ($this->_method == GET) {
         $url = $url . http_build_query($data);
         $this->_result = Request::get($url)->send();
     } else {
         if ($this->_method == POST) {
             if (isset($apiKey)) {
                 $url .= array_keys($apiKey)[0] . "=" . array_values($apiKey)[0];
             }
             $request = Request::post($url);
             foreach ($this->_headers as $key => $hdr) {
                 $request = $request->addHeader($key, $hdr);
             }
             if ($this->headers["Content-Type"] = "application/x-www-form-urlencoded" and is_array($data)) {
                 $request = $request->body(http_build_query($data));
             } else {
                 $request = $request->body($data);
             }
             if (isset($auth)) {
                 $request = $request->authenticateWith(array_keys($auth)[0], array_values($auth)[0]);
             }
             $this->_result = $request->send();
         }
     }
 }
开发者ID:sumutcan,项目名称:SIWCMS,代码行数:27,代码来源:Operation.php

示例7: read

 function read($pgt_iou)
 {
     $response = Request::post(Config::get('pgtservice.endpoint'), array('Username' => Config::get('pgtservice.username'), 'Password' => Config::get('pgtservice.password'), 'PGTIOU' => $pgt_iou), Mime::FORM)->addHeader('Content-Type', 'application/x-www-form-urlencoded')->send();
     $dom = new \DOMDocument();
     $dom->loadXML($response->raw_body);
     return $dom->documentElement->textContent;
 }
开发者ID:GlobalTechnology,项目名称:mpd-dashboard-app,代码行数:7,代码来源:ProxyTicketServiceStorage.php

示例8: publish

 public function publish($topic, $data)
 {
     $body = ['topic' => $topic, 'payload' => $data];
     try {
         $request = \Httpful\Request::post('http://localhost:9999/mqtt/publish')->sendsJson()->body(json_encode($body))->send();
     } catch (\Exception $e) {
     }
 }
开发者ID:zhoumingchun,项目名称:beehive-web,代码行数:8,代码来源:HttpPublishBridge.php

示例9: auth

 /**
  * @param $login
  * @param $password
  * @return string|false
  */
 public function auth($login, $password)
 {
     $resp = Request::post($this->config['host'] . $this->config['endpoints']['auth'])->sendsType(Mime::FORM)->body(http_build_query(['login' => $login, 'password' => $password]))->send();
     if ($resp->hasErrors()) {
         return false;
     }
     return $resp->body[0];
 }
开发者ID:petitkoalak,项目名称:al-client,代码行数:13,代码来源:Client.php

示例10: postExternal

 /**
  * @param string $receiptData
  * @param string $sharedSecret
  * @return array
  * @throws IAPServerUnavailableException
  */
 private function postExternal($receiptData, $sharedSecret)
 {
     if (!getenv('APPLE_IAP_VERIFY_URL')) {
         throw new IAPServerUnavailableException('An endpoint for polling apple was not found. Please ensure one is set.', 100021005);
     }
     $response = Request::post(getenv('APPLE_IAP_VERIFY_URL'))->body($this->buildFormattedArray($receiptData, $sharedSecret))->sendsType(Mime::JSON)->send();
     return json_decode($response->body, true);
 }
开发者ID:srleach,项目名称:inapp-verify,代码行数:14,代码来源:AppleApiHelper.php

示例11: send

 /**
  * Send the HipChat message.
  *
  * @return mixed
  */
 public function send()
 {
     $message = $this->message ?: ucwords($this->getSystemUser()) . ' ran the [' . $this->task . '] task.';
     $format = $message != strip_tags($message) ? 'html' : 'text';
     $query = ['auth_token' => $this->token];
     $payload = ['from' => $this->from, 'message' => $message, 'message_format' => $format, 'notify' => true, 'color' => $this->color];
     return Request::post('https://api.hipchat.com/v2/room/' . $this->room . '/notification?' . http_build_query($query))->sendsJson()->body(json_encode($payload))->send();
 }
开发者ID:laravel,项目名称:envoy,代码行数:13,代码来源:Hipchat.php

示例12: send

 /**
  * @param string $message
  *
  * @return Response
  */
 public function send($message = null)
 {
     if (!is_null($message)) {
         $this->setMessage($message);
     }
     /** @var Request $request */
     $request = Request::post($this->endpoint, $this->message, 'application/xml');
     return $request->withoutAutoParsing()->send();
 }
开发者ID:danielcosta,项目名称:redecard-ecommerce,代码行数:14,代码来源:Client.php

示例13: getToken

 function getToken($secret)
 {
     $headers = array("Authorization" => "Basic " . $secret, "Content-Type" => "application/x-www-form-urlencoded");
     $response = Request::post($this->apiUrl . "/auth/token")->addHeaders($headers)->body("grant_type=client_credentials")->send();
     $resArr = json_decode($response);
     if (array_key_exists('access_token', $resArr)) {
         return $resArr->access_token;
     }
 }
开发者ID:riseofthetigers,项目名称:SabrePhpBridge,代码行数:9,代码来源:sabreapi.php

示例14: post

 public function post($url, $data)
 {
     $request = \Httpful\Request::post($this->endpointUrl . $url)->expectsJson()->addHeader('Authorization', 'Bearer ' . $this->accessToken);
     if (!is_null($data)) {
         $request->sendsJson()->body(json_encode($data));
     }
     $httpResponse = $request->send();
     return $httpResponse->body;
 }
开发者ID:silvioclipper,项目名称:RestPkiSamples,代码行数:9,代码来源:RestPkiLegacy.php

示例15: addPropertiesToUser

 public function addPropertiesToUser($email, array $properties, array $attributes)
 {
     $payload = array('subscriber' => array("uid" => $email, "properties" => $properties, "attributes" => $attributes));
     $response = Httpful\Request::post('https://api.boomtrain.net/201507/subscribers/identify')->sendsAndExpects('application/json')->basicAuth('api', $this->apiKey)->body($payload)->sendIt();
     if ($response->code != 200) {
         throw new \Exception($response->body->error);
     } else {
         return $response->body;
     }
 }
开发者ID:usterix,项目名称:laravel-boomtrain,代码行数:10,代码来源:Boomtrain.php


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