本文整理汇总了PHP中Requests::put方法的典型用法代码示例。如果您正苦于以下问题:PHP Requests::put方法的具体用法?PHP Requests::put怎么用?PHP Requests::put使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Requests
的用法示例。
在下文中一共展示了Requests::put方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: issue_request
function issue_request($render, $url, $headers, $body)
{
if ($render['METHOD'] == 'POST') {
return \Requests::post($url, $headers, $body);
} else {
if ($render['METHOD'] == 'PUT') {
return \Requests::put($url, $headers, $body);
} else {
if ($render['METHOD'] == 'DELETE') {
return \Requests::delete($url, $headers);
}
}
}
return \Requests::get($url, $headers);
}
示例2: testPUTWithArray
public function testPUTWithArray()
{
$data = array('test' => 'true', 'test2' => 'test');
$request = Requests::put(httpbin('/put'), 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']);
}
示例3: putAPI
function putAPI($method, $function, $params = [], $data = [], $keep = TRUE)
{
$params = is_array($params) ? $params : (array) $params;
$params = count($params) < 1 ? '' : '?' . http_build_query($params);
$headers = ['X-API-KEY' => APPLICATION_KEY, 'TOKEN' => $this->session->userdata('token')];
$response = Requests::put(API_URL . $method . '/' . $function . $params, $headers, $data);
$result = json_decode($response->body);
// UPDATE TOKEN TO SESSION
if (!empty($result->token)) {
if ((bool) $this->session->userdata('user_id')) {
$this->session->set_userdata('token', $result->token);
}
}
$output['execution_time_api'] = $result->execution_time;
$output['environment_api'] = $result->environment;
$output['message'] = $result->message;
// OUTPUT
if (!$keep) {
$this->xresponse($result->status, $output, $response->status_code);
} else {
return $result;
}
}
示例4:
$req = Requests::get($url . '/multi');
$tf->assertSame($req->body, 'MULTI /multi');
$req = Requests::put($url . '/multi');
$tf->assertSame($req->body, 'MULTI /multi');
$req = Requests::post($url . '/multi');
$tf->assertSame($req->body, 'MULTI /multi');
$req = Requests::delete($url . '/multi');
$tf->assertNotSame($req->body, 'MULTI /multi');
$req = Requests::get($url . '/any');
$tf->assertSame($req->body, 'ANY /any');
$req = Requests::post($url . '/any');
$tf->assertSame($req->body, 'ANY /any');
$req = Requests::put($url . '/any');
$tf->assertSame($req->body, 'ANY /any');
$req = Requests::delete($url . '/any');
$tf->assertSame($req->body, 'ANY /any');
// $req = Requests::head($url . '/any');
// $tf->assertSame($req->body, 'ANY /any');
$req = Requests::get($url . '/space/');
$tf->assertSame($req->body, 'GET /space/');
$req = Requests::post($url . '/space/');
$tf->assertSame($req->body, 'POST /space/');
$req = Requests::get($url . '/_all');
$tf->assertSame($req->body, 'all');
$req = Requests::post($url . '/_all');
$tf->assertSame($req->body, 'all');
$req = Requests::post($url . '/lla');
$tf->assertSame($req->body, 'all');
$req = Requests::put($url . '/all');
$tf->assertSame($req->body, 'all');
});
示例5: _request
/**
* DSL wrapper to make a HTTP request based on supported HTTP methods.
*
* @param string $uri Path to API resource
* @param array $args Associative array of passed arguments
* @param array $headers List of passed headers
* @param string $method HTTP method
* @return array Processed response
* @see Sixreps::_response
*/
protected function _request($uri, $args = array(), $headers = array(), $method = 'GET')
{
$url = $this->_host . trim($uri, '/');
switch ($method) {
case 'GET':
if (!empty($args)) {
$url = $url . '?' . http_build_query($args);
}
$request = Requests::get($url, array());
break;
case 'POST':
$request = Requests::post($url, array(), $args);
break;
case 'PUT':
$request = Requests::put($url, array(), $args);
break;
case 'DELETE':
if (!empty($args)) {
$url = $url . '?' . http_build_query($args);
}
$request = Requests::delete($url, array());
break;
default:
throw new InvalidArgumentException(sprintf('Unsupported %s HTTP method. It should match one of %s keywords.', $method, implode(', ', $this->_http_methods)));
}
$body = $request->body;
$info['headers'] = $request->headers;
$info['headers'] = $request->headers;
$info['status_code'] = $request->status_code;
$info['success'] = $request->success;
$info['redirects'] = $request->redirects;
$info['url'] = $request->url;
return $this->_response($body, $info, $method);
}
示例6: setItemSnapshot
/**
* Send a PUT items request to vwflow to update the snapshot that is being used for a given item.
*
* @param string $item_id ID of the item.
* @param int $snapshot_id ID of the snapshot to be set.
* @throws Exception If an error response was returned by VWflow
*/
function setItemSnapshot($item_id, $snapshot_id)
{
$url = $this->uri . "items/" . $item_id . "/";
$headers = array('Content-Type' => 'application/json');
$response = Requests::put($url, $headers, json_encode(array("snapshot_id" => $snapshot_id)), $this->request_options);
$this->_checkErrorResponse($response);
return json_decode($response->body);
}
示例7: update
/**
* Update the object
*
* @throws Requests_Exception Failed to update the object
* @throws Exception Failed to decode JSON
* @param array $data Data to update, in addition to already changed data
* @param boolean $use_json Use a JSON body rather than form-encoded data
* @param boolean $check_modification Should we change the last modified date? Avoids editing conflicts
* @return boolean Was the update successful?
*/
public function update($data = array(), $use_json = true, $check_modification = true)
{
$keys = array_keys($this->changed);
$values = array();
if (!empty($data)) {
$values = array_merge($values, array_diff_assoc($data, $this->data));
}
// Don't send the ID with the data
unset($values['ID']);
$headers = array();
if ($use_json) {
$body = json_encode($values);
$headers['Content-Type'] = 'application/json';
} else {
$body = array('data' => $values);
}
if ($check_modification) {
$headers['If-Unmodified-Since'] = date(DateTime::RFC1123, strtotime($this->modified));
}
$response = Requests::put($this->meta['links']['self'], $headers, $body, $this->api->getDefaultOptions());
$response->throw_for_status();
$this->data = json_decode($response->body, true);
$this->changed = array();
return true;
}
示例8: retry
/**
* Method to set how many times a request should be retried
*
* @param integer $retry_count how many times to retry a request
*
* @return string
*/
public function retry($retry_count)
{
$data = $this->_encodeArray(array('retrycount' => $retry_count));
$url = "http://{$this->browsermob_url}/proxy/{$this->port}/retry";
$response = Requests::put($url, array(), $data);
return $response;
}
示例9: doPut
function doPut($url, $payload = "")
{
$response = Requests::put($this->apiUrl . $url, $this->header, $payload);
return json_decode($response->body);
}
示例10: routes
$tf->assertSame($req->body, "regex ([a-zA-Z_-]+) _");
$req = Requests::get($url . '/r/ReGeX_');
$tf->assertSame($req->body, "regex ([a-zA-Z_-]+) ReGeX_");
$req = Requests::get($url . '/r/ReGeX');
$tf->assertSame($req->body, "regex [a-zA-Z]+");
$req = Requests::get($url . '/r/0');
$tf->assertSame($req->body, "regex .+");
});
$tf->test("Advanced routes (controller)", function ($tf) {
$url = URL . "routes.php";
$req = Requests::get($url . '/c/0');
$tf->assertSame($req->body, "method", "Call method");
$req = Requests::get($url . '/c/1');
$tf->assertSame($req->body, "methodNextmethod2", "Call method and test \$next()");
$req = Requests::get($url . '/c/2/Method');
$tf->assertSame($req->body, "GET test", "Call getMethod()");
$req = Requests::get($url . '/c/2/Method2');
$tf->assertSame($req->body, "GET test2", "Call gEtMeThOd2()");
$req = Requests::post($url . '/c/2/Method');
$tf->assertNotSame($req->body, "POST test", "Cannot call postMethod()");
$req = Requests::get($url . '/c/3/Method/sufix');
$tf->assertSame($req->body, "GET test", "Call getMethod() 2");
$req = Requests::get($url . '/c/3/Method/abc');
$tf->assertNotSame($req->body, "GET test", "Not getMethod() 2");
$req = Requests::get($url . '/c/4/Method');
$tf->assertSame($req->body, "GET test", "Call getMethod()");
$req = Requests::post($url . '/c/4/Method');
$tf->assertSame($req->body, "POST test", "Call postMethod()");
$req = Requests::put($url . '/c/4/Method');
$tf->assertSame($req->body, "PUT test", "Call putMethod()");
});
示例11: put
protected function put($uri, $timeout)
{
$response = \Requests::put($uri, array(), ['timeout' => ceil($timeout)]);
$this->checkErrors($response);
return $response->body;
}
示例12: unset
<?php
include 'baseline.php';
$update_double_opt_url = $config['BASEURL'] . '/doubleopt/' . $request->double_opt_key;
unset($request->double_opt_key);
$request->location_id = $config['LOCATION_ID'];
$request->nyhedsbreve = array($config['GODTTIP_NID']);
$headers = array('Content-Type' => 'application/json');
$response = Requests::put($update_double_opt_url, $headers, json_encode($request));
echo $response->body;
示例13: array_push
<?php
include 'baseline.php';
$user_put = $config['BASEURL'] . '/users/' . $request->ekstern_id;
$request->location_id = $config['LOCATION_ID'];
array_push($request->nyhedsbreve, $config['TBT_NID']);
$response = Requests::put($user_put, $headers, json_encode($request));
echo $response->body;