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


PHP Requests::put方法代码示例

本文整理汇总了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);
}
开发者ID:coviu,项目名称:coviu-video-calls,代码行数:15,代码来源:Request.php

示例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']);
 }
开发者ID:majinhui04,项目名称:pretty,代码行数:8,代码来源:Base.php

示例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;
     }
 }
开发者ID:antho-firuze,项目名称:_g.ene.sys_remake_,代码行数:23,代码来源:Getme.php

示例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');
});
开发者ID:bafs,项目名称:via,代码行数:31,代码来源:methodsTest.php

示例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);
 }
开发者ID:rizarsyi,项目名称:sixreps-php-sdk,代码行数:44,代码来源:Sixreps.php

示例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);
 }
开发者ID:vwflow,项目名称:vwflow-php,代码行数:15,代码来源:VWflow.php

示例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;
 }
开发者ID:NikDevPHP,项目名称:client-php,代码行数:35,代码来源:Object.php

示例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;
 }
开发者ID:jjanvier,项目名称:PHPBrowserMobProxy,代码行数:14,代码来源:Client.php

示例9: doPut

 function doPut($url, $payload = "")
 {
     $response = Requests::put($this->apiUrl . $url, $this->header, $payload);
     return json_decode($response->body);
 }
开发者ID:replay42,项目名称:JodelPHP,代码行数:5,代码来源:jodel.class.php

示例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()");
});
开发者ID:bafs,项目名称:via,代码行数:31,代码来源:routesTest.php

示例11: put

 protected function put($uri, $timeout)
 {
     $response = \Requests::put($uri, array(), ['timeout' => ceil($timeout)]);
     $this->checkErrors($response);
     return $response->body;
 }
开发者ID:recombee,项目名称:php-api-client,代码行数:6,代码来源:Client.php

示例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;
开发者ID:BerlingskeMedia,项目名称:godttip,代码行数:10,代码来源:update_double_opt.php

示例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;
开发者ID:BerlingskeMedia,项目名称:thebusinesstarget,代码行数:8,代码来源:edit.php


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