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


PHP Request::patch方法代码示例

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


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

示例1: testPatch

 public function testPatch()
 {
     $response = Request::patch('http://mockbin.com/request', array('Accept' => 'application/json'), array('name' => 'Mark', 'nick' => 'thefosk'));
     $this->assertEquals(200, $response->code);
     $this->assertEquals('PATCH', $response->body->method);
     $this->assertEquals('Mark', $response->body->postData->params->name);
     $this->assertEquals('thefosk', $response->body->postData->params->nick);
 }
开发者ID:RusinovIG,项目名称:unirest-php,代码行数:8,代码来源:RequestTest.php

示例2: call

 /**
  * The underlying call to the Kong Server
  *
  * @throws \Ignittion\Kong\KongException when something goes wrong with the Http request
  *
  * @param string $verb
  * @param string $uri
  * @param array $options
  * @param array $body
  * @return \stdClass
  */
 public function call($verb, $uri, array $params = [], array $body = [], array $headers = [])
 {
     $verb = strtoupper($verb);
     $api = "{$this->url}:{$this->port}/{$uri}";
     $headers = array_merge($headers, ['Content-Type: application/json']);
     try {
         switch ($verb) {
             case 'GET':
                 $request = RestClient::get($api, $headers, $params);
                 break;
             case 'POST':
                 $request = RestClient::post($api, $headers, $body);
                 break;
             case 'PUT':
                 $request = RestClient::put($api, $headers, $body);
                 break;
             case 'PATCH':
                 $request = RestClient::patch($api, $headers, $body);
                 break;
             case 'DELETE':
                 $request = RestClient::delete($api, $headers);
                 break;
             default:
                 throw new Exception('Unknown HTTP Request method.');
         }
     } catch (Exception $e) {
         throw new KongException($e->getMessage());
     }
     // save this request
     $this->body = $request->body;
     $this->headers = $request->headers;
     $this->httpCode = $request->code;
     $this->rawBody = $request->raw_body;
     // return a more simplified response
     $object = new stdClass();
     $object->code = $this->httpCode;
     $object->data = $this->body;
     return $object;
 }
开发者ID:ignittion,项目名称:kong-php,代码行数:50,代码来源:AbstractApi.php


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