本文整理汇总了PHP中Requests::patch方法的典型用法代码示例。如果您正苦于以下问题:PHP Requests::patch方法的具体用法?PHP Requests::patch怎么用?PHP Requests::patch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Requests
的用法示例。
在下文中一共展示了Requests::patch方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getOrderInfo
public function getOrderInfo($accountId, $orderId)
{
$order = \Requests::patch($this->getUrl() . 'accounts/' . $accountId . '/orders/' . $orderId, array('Authorization' => 'Bearer ' . $this->getToken(), 'Content-Type' => 'application/json'));
//$this->checkAnswer($order);
print_r($order->headers);
return $order;
}
示例2: request
public function request($method, $url, $api_key, $data = NULL, $headers = array("Content-Type" => "application/json", "Accept" => "application/json"))
{
try {
$options = array('auth' => new \Requests_Auth_Basic(array($api_key, '')));
if ($method == "GET") {
$url_params = is_array($data) ? '?' . http_build_query($data) : '';
$response = \Requests::get(Client::BASE_URL . $url . $url_params, $headers, $options);
} else {
if ($method == "POST") {
$response = \Requests::post(Client::BASE_URL . $url, $headers, json_encode($data), $options);
} else {
if ($method == "PATCH") {
$response = \Requests::patch(Client::BASE_URL . $url, $headers, json_encode($data), $options);
} else {
if ($method == "DELETE") {
$response = \Requests::delete(Client::BASE_URL . $url, $headers, $options);
}
}
}
}
} catch (\Exception $e) {
throw new UnableToConnect();
}
if ($response->status_code >= 200 && $response->status_code <= 206) {
if ($method == "DELETE") {
return $response->status_code == 204 || $response->status_code == 200;
}
return json_decode($response->body);
}
if ($response->status_code == 400) {
$code = 0;
$message = "";
try {
$error = (array) json_decode($response->body)->errors[0];
$code = key($error);
$message = current($error);
} catch (\Exception $e) {
throw new UnhandledError($response->body, $response->status_code);
}
throw new InputValidationError($message, $code);
}
if ($response->status_code == 401) {
throw new AuthenticationError();
}
if ($response->status_code == 404) {
throw new NotFound();
}
if ($response->status_code == 403) {
throw new InvalidApiKey();
}
if ($response->status_code == 405) {
throw new MethodNotAllowed();
}
throw new UnhandledError($response->body, $response->status_code);
}
示例3: request
public function request($method, $url, $api_key, $data = NULL, $headers = array("Content-Type" => "application/json", "Accept" => "application/json"))
{
try {
$options = array('auth' => new AuthBearer($api_key), 'timeout' => 120);
if ($method == "GET") {
$url_params = is_array($data) ? '?' . http_build_query($data) : '';
$response = \Requests::get(Culqi::$api_base . $url . $url_params, $headers, $options);
} else {
if ($method == "POST") {
$response = \Requests::post(Culqi::$api_base . $url, $headers, json_encode($data), $options);
} else {
if ($method == "PATCH") {
$response = \Requests::patch(Culqi::$api_base . $url, $headers, json_encode($data), $options);
} else {
if ($method == "DELETE") {
$response = \Requests::delete(Culqi::$api_base, $options);
}
}
}
}
} catch (\Exception $e) {
throw new Errors\UnableToConnect();
}
if ($response->status_code >= 200 && $response->status_code <= 206) {
if ($method == "DELETE") {
return $response->status_code == 204 || $response->status_code == 200;
}
return json_decode($response->body);
}
if ($response->status_code == 400) {
$code = 0;
$message = "";
throw new Errors\UnhandledError($response->body, $response->status_code);
}
if ($response->status_code == 401) {
throw new Errors\AuthenticationError();
}
if ($response->status_code == 404) {
throw new Errors\NotFound();
}
if ($response->status_code == 403) {
throw new Errors\InvalidApiKey();
}
if ($response->status_code == 405) {
throw new Errors\MethodNotAllowed();
}
throw new Errors\UnhandledError($response->body, $response->status_code);
}
示例4: request
protected function request($method, $url, $client_id, $secret_id, $data = NULL, $headers = array("Content-Type" => "application/json", "Accept" => "application/json"))
{
try {
$options = array('auth' => new \Requests_Auth_Basic(array($client_id, $secret_id)));
if ($method == "GET") {
$url_params = is_array($data) ? '?' . http_build_query($data) : '';
$response = \Requests::get($this->base_url . $url . $url_params, $headers, $options);
} else {
if ($method == "POST") {
$response = \Requests::post($this->base_url . $url, $headers, json_encode($data), $options);
} else {
if ($method == "PATCH") {
$response = \Requests::patch($this->base_url . $url, $headers, json_encode($data), $options);
} else {
if ($method == "DELETE") {
$response = \Requests::delete($this->base_url . $url, $headers, $options);
}
}
}
}
} catch (\Exception $e) {
throw new \Exception(Error_Message::ERROR_CONNECTION);
}
if ($response->status_code >= 200 && $response->status_code <= 206) {
if ($method == "DELETE") {
return $response->status_code == 204 || $response->status_code == 200;
}
return json_decode($response->body);
}
if ($response->status_code >= 400 && $response->status_code <= 406) {
try {
$error = (array) json_decode($response->body);
$code = $error['errorCode'];
$message = $error['errorMessage'];
} catch (\Exception $e) {
throw new \Exception($response->body, $response->status_code);
}
throw new \Exception($message, $code);
}
throw new \Exception($response->body, $response->status_code);
}
示例5: testPATCHWithArray
public function testPATCHWithArray()
{
$data = array('test' => 'true', 'test2' => 'test');
$request = Requests::patch(httpbin('/patch'), array(), $data, $this->getOptions());
$this->assertEquals(200, $request->status_code);
$result = json_decode($request->body, true);
$this->assertEquals(array('test' => 'true', 'test2' => 'test'), $result['form']);
}