本文整理汇总了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);
}
示例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;
}