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


PHP HttpRequest::getPostFields方法代码示例

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


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

示例1: ajaxAction

 public function ajaxAction()
 {
     $this->view = new Lupin_View();
     $method = strtolower($this->_request->getParam('method'));
     $query_uri = trim($this->_request->getParam('query_uri'), '/ ');
     $url = $this->_request->getParam('url');
     $extraParams = $this->_request->getParam('param');
     $params = array('format' => $this->_request->getParam('format'));
     if (!empty($extraParams)) {
         foreach ($extraParams as $newParam) {
             $parms = explode('=', $newParam, 2);
             if (count($parms) > 1) {
                 list($key, $value) = $parms;
                 $params[$key] = $value;
             }
         }
     }
     $newMethod = HTTP_METH_GET;
     switch ($method) {
         case 'get':
             $newMethod = HTTP_METH_GET;
             break;
         case 'post':
             $newMethod = HTTP_METH_POST;
             break;
         case 'put':
             $newMethod = HTTP_METH_PUT;
             break;
         case 'delete':
             $newMethod = HTTP_METH_DELETE;
             break;
         case 'head':
             $newMethod = HTTP_METH_HEAD;
             break;
     }
     $email = $this->_request->getParam('email');
     $pass = $this->_request->getParam('secretKey');
     $request_url = 'http://' . $url . '/' . $query_uri;
     $request = new HttpRequest($request_url, $newMethod);
     if ($email && $pass) {
         $encoded_auth = base64_encode($email . ':' . $pass);
         $request->addHeaders(array('Authorization' => 'Basic ' . $encoded_auth));
     }
     if ("post" == $method) {
         $request->addPostFields($params);
     } else {
         $request->addQueryData($params);
     }
     $res = $request->send();
     function collapseHeaders($headers)
     {
         $header_string = "";
         foreach ($headers as $name => $value) {
             $header_string .= $name . ": " . wordwrap($value, 45, "\n\t") . "\n";
         }
         return $header_string;
     }
     $responseInfo = $request->getResponseInfo();
     $response = array('request_url' => $responseInfo['effective_url'], 'response_headers' => collapseHeaders($res->getHeaders()), 'content' => $res->getBody(), 'status' => $res->getResponseCode(), 'method' => strtoupper($method), 'request_post_fields' => http_build_query(!is_null($postFields = $request->getPostFields()) ? $postFields : array()));
     $this->view->renderJson($response);
 }
开发者ID:jeremykendall,项目名称:spaz-api,代码行数:61,代码来源:TesterController.php

示例2: ajaxAction

 public function ajaxAction()
 {
     $this->view = new Lupin_View();
     $method = strtolower($this->_request->getParam('method'));
     $query_uri = trim($this->_request->getParam('query_uri'), '/ ');
     $url = $this->_request->getParam('url');
     $ssl = $this->_request->getParam('ssl');
     $extraParams = $this->_request->getParam('param');
     $params = array();
     if (!empty($extraParams)) {
         foreach ($extraParams as $newParam) {
             $parms = explode('=', $newParam, 2);
             if (count($parms) > 1) {
                 list($key, $value) = $parms;
                 $params[$key] = $value;
             }
         }
     }
     $newMethod = HTTP_METH_GET;
     switch ($method) {
         case 'get':
             $newMethod = HTTP_METH_GET;
             break;
         case 'post':
             $newMethod = HTTP_METH_POST;
             break;
         case 'put':
             $newMethod = HTTP_METH_PUT;
             break;
         case 'delete':
             $newMethod = HTTP_METH_DELETE;
             break;
         case 'head':
             $newMethod = HTTP_METH_HEAD;
             break;
     }
     $email = $this->_request->getParam('email');
     $pass = $this->_request->getParam('secretKey');
     $request_url = 'http' . ($ssl !== null ? 's' : '') . '://' . $url . '/' . $query_uri;
     $httpOptions = array();
     if ($email && $pass) {
         $httpOptions = array('headers' => array('Accept' => '*/*'), 'httpauth' => $email . ':' . $pass, 'httpauthtype' => HTTP_AUTH_DIGEST);
     }
     $request = new HttpRequest($request_url, $newMethod, $httpOptions);
     if ("post" == $method) {
         $request->addPostFields($params);
     } else {
         $request->addQueryData($params);
     }
     $res = $request->send();
     $responseInfo = $request->getResponseInfo();
     $response = array('request_url' => $responseInfo['effective_url'], 'response_headers' => $this->collapseHeaders($res->getHeaders()), 'content' => $res->getBody(), 'status' => $res->getResponseCode(), 'method' => strtoupper($method), 'request_post_fields' => http_build_query(!is_null($postFields = $request->getPostFields()) ? $postFields : array()));
     $this->view->renderJson($response);
 }
开发者ID:jeremykendall,项目名称:frapi,代码行数:54,代码来源:TesterController.php

示例3: signRequestV2

 /**
  * Signs request with signature version 2
  *
  * Only POST http method is supported
  *
  * @param   \HttpRequest $request Http request object
  * @throws  QueryClientException
  */
 protected function signRequestV2($request)
 {
     $time = time();
     //Gets the http method name
     $httpMethod = self::$httpMethods[$request->getMethod()];
     //Gets both host and path from the url
     $components = parse_url($request->getUrl());
     $common = ['AWSAccessKeyId' => $this->awsAccessKeyId, 'SignatureVersion' => '2', 'SignatureMethod' => 'HmacSHA1', 'Timestamp' => gmdate('Y-m-d\\TH:i:s', $time) . "Z"];
     $request->addPostFields($common);
     //Gets adjusted options
     $options = $request->getPostFields();
     //Calculating canonicalized query string
     ksort($options);
     $canonicalizedQueryString = '';
     foreach ($options as $k => $v) {
         $canonicalizedQueryString .= '&' . rawurlencode($k) . '=' . rawurlencode($v);
     }
     $canonicalizedQueryString = ltrim($canonicalizedQueryString, '&');
     $stringToSign = $httpMethod . "\n" . strtolower($components['host']) . "\n" . $components['path'] . "\n" . $canonicalizedQueryString;
     switch ($common['SignatureMethod']) {
         case 'HmacSHA1':
         case 'HmacSHA256':
             $algo = strtolower(substr($common['SignatureMethod'], 4));
             break;
         default:
             throw new QueryClientException('Unknown SignatureMethod ' . $common['SignatureMethod']);
     }
     $request->addPostFields(['Signature' => base64_encode(hash_hmac($algo, $stringToSign, $this->secretAccessKey, 1))]);
     $request->addHeaders(['X-Amz-Date' => gmdate(\DateTime::ISO8601, $time)]);
 }
开发者ID:sacredwebsite,项目名称:scalr,代码行数:38,代码来源:QueryClient.php

示例4: var_dump

<?php

var_dump(HttpRequest::getPostFields());
die;
开发者ID:vkphillia,项目名称:survaider_app_free,代码行数:4,代码来源:response.php


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