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


PHP Client::put方法代码示例

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


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

示例1: upload

 public function upload($file, $remote_path, $chunk_size)
 {
     if (!file_exists($file) || !is_readable($file) || !($fp = fopen($file, 'rb'))) {
         throw new \Exception(sprintf(__('The file %s does not seem to exist or is not readable.', 'my-wp-backup'), $file));
     }
     $upload_id = null;
     while (!feof($fp)) {
         try {
             $res = $this->client->put('chunked_upload', null, array('upload_id' => $upload_id, 'offset' => ftell($fp)))->setBody(wpb_get_file_chunk($fp, $chunk_size))->send()->json();
             if (null === $upload_id) {
                 $upload_id = $res['upload_id'];
             }
         } catch (BadResponseException $e) {
             $body = $e->getResponse()->getBody(true);
             error_log($e->getRequest()->getRawHeaders());
             error_log($body);
             throw new \Exception($body);
         }
     }
     $req = $this->client->post('commit_chunked_upload/auto/' . ltrim($remote_path, '/'), null, array('upload_id' => $upload_id, 'overwrite' => 'true'));
     try {
         return $req->send()->json();
     } catch (BadResponseException $e) {
         $body = $e->getResponse()->getBody(true);
         error_log($e->getRequest()->getRawHeaders());
         error_log($body);
         throw new \Exception($body);
     }
 }
开发者ID:akochnov,项目名称:fts,代码行数:29,代码来源:Dropbox.php

示例2: put

 /**
  * @inheritdoc
  */
 public function put($url, $params)
 {
     $request = $this->client->put($url, null, json_encode($params));
     $this->setHeaders($request);
     $response = $request->send();
     return $response->getStatusCode() == 204;
 }
开发者ID:erliz,项目名称:jira-api-client-guzzle-provider,代码行数:10,代码来源:Client.php

示例3: customer

 /**
  * Send Create/Update Customer Request
  * @param $id
  * @param $email
  * @param $attributes
  * @return Response
  */
 public function customer($id, $email, $attributes)
 {
     $body = array_merge(array('email' => $email), $attributes);
     try {
         $response = $this->client->put('/api/v1/customers/' . $id, null, $body, array('auth' => $this->auth))->send();
     } catch (RequestException $e) {
         $response = $e->getResponse();
     }
     return new Response($response->getStatusCode(), $response->getReasonPhrase());
 }
开发者ID:Seekube,项目名称:php-customerio,代码行数:17,代码来源:Request.php

示例4: enqueue

 /**
  * Queue an array of responses or a single response on the server.
  *
  * Any currently queued responses will be overwritten.  Subsequent requests
  * on the server will return queued responses in FIFO order.
  *
  * @param array|Response $responses A single or array of Responses to queue
  * @throws BadResponseException
  */
 public function enqueue($responses)
 {
     $data = array();
     foreach ((array) $responses as $response) {
         // Create the response object from a string
         if (is_string($response)) {
             $response = Response::fromMessage($response);
         } elseif (!$response instanceof Response) {
             throw new BadResponseException('Responses must be strings or implement Response');
         }
         $data[] = array('statusCode' => $response->getStatusCode(), 'reasonPhrase' => $response->getReasonPhrase(), 'headers' => $response->getHeaders()->toArray(), 'body' => $response->getBody(true));
     }
     $request = $this->client->put('guzzle-server/responses', null, json_encode($data));
     $request->send();
 }
开发者ID:carlesgutierrez,项目名称:libreobjet.org,代码行数:24,代码来源:Server.php

示例5: put

 /**
  * @param $endpointUrl
  * @param $putData
  * @return \stdClass
  * @throws GenericHTTPError
  * @throws InvalidCredentials
  * @throws MissingEndpoint
  * @throws MissingRequiredParameters
  */
 public function put($endpointUrl, $putData)
 {
     $request = $this->mgClient->put($endpointUrl, array(), $putData);
     $request->getPostFields()->setAggregator(new DuplicateAggregator());
     $response = $request->send();
     return $this->responseHandler($response);
 }
开发者ID:sysatom,项目名称:workflow,代码行数:16,代码来源:RestClient.php

示例6: putSlots

 /**
  * @param int             $facilityId
  * @param int             $doctorId
  * @param int             $addressId
  *
  * @param PutSlotsRequest $putSlots
  *
  * @return PutSlotsResponse
  */
 public function putSlots($facilityId, $doctorId, $addressId, $putSlots)
 {
     $requestBody = $this->serializer->serialize($putSlots, 'json', SerializationContext::create()->setGroups(['Default', 'put_slots']));
     $request = $this->client->put(['facilities/{facilityId}/doctors/{doctorId}/addresses/{addressId}/slots', ['facilityId' => $facilityId, 'doctorId' => $doctorId, 'addressId' => $addressId]], null, $requestBody);
     $putSlotResponse = $this->authorizedRequest($request, PutSlotsResponse::class);
     return $putSlotResponse;
 }
开发者ID:umitakkaya,项目名称:sample-api-client,代码行数:16,代码来源:DPClient.php

示例7: creat_user

function creat_user()
{
    $name = uniqid('riakcs-');
    $client = new Client('http://localhost:' . cs_port());
    $request = $client->put('/riak-cs/user', array('Content-Type' => 'application/json'), "{\"name\":\"{$name}\", \"email\":\"{$name}@example.com\"}");
    return $request->send()->json();
}
开发者ID:mgoddard-pivotal,项目名称:riak_cs,代码行数:7,代码来源:bootstrap.php

示例8: update

 /**
  * @param NewConnectionRevision $newRevision
  * @return Connection
  */
 public function update(NewConnectionRevision $newRevision)
 {
     $url = $this->getConnectionUrl($newRevision->getConnection()->getId());
     $request = $this->client->put($this->client->getBaseUrl() . $url, $this->HEADERS, $this->serializer->serialize($this->disassembler->disassemble($newRevision), 'json'));
     $response = $request->send();
     $this->statusCodeValidator->validate(201, $url, $request, $response);
     return $this->mapJsonToConnection($response->getBody(true));
 }
开发者ID:janus-ssp,项目名称:client,代码行数:12,代码来源:ConnectionRepository.php

示例9: httpPut

 /**
  * Send a simple put request to the Elasticsearch server.
  *
  * @param $uri
  * @param array $data
  *
  * @return \Guzzle\Http\Message\Response
  */
 public static function httpPut($uri, $data = null)
 {
     $client = new HttpClient();
     $host = Config::getFirstHost();
     if ($data) {
         $data = json_encode($data);
     }
     return $client->put($host . '/' . $uri, null, $data)->send();
 }
开发者ID:wallmanderco,项目名称:elasticsearch-indexer,代码行数:17,代码来源:Elasticsearch.php

示例10: testAddsBody

 public function testAddsBody()
 {
     $this->getServer()->flush();
     $this->getServer()->enqueue("HTTP/1.1 200 OK\r\nContent-Length: 2\r\n\r\nhi");
     $request = $this->client->put('/', array('Foo' => 'Bar'), 'Testing...123');
     $stream = $this->factory->fromRequest($request);
     $this->assertEquals('hi', (string) $stream);
     $headers = $this->factory->getLastResponseHeaders();
     $this->assertContains('HTTP/1.1 200 OK', $headers);
     $this->assertContains('Content-Length: 2', $headers);
     $this->assertSame($headers, $stream->getCustomData('response_headers'));
     $received = $this->getServer()->getReceivedRequests();
     $this->assertEquals(1, count($received));
     $this->assertContains('PUT / HTTP/1.1', $received[0]);
     $this->assertContains('host: ', $received[0]);
     $this->assertContains('user-agent: Guzzle/', $received[0]);
     $this->assertContains('foo: Bar', $received[0]);
     $this->assertContains('content-length: 13', $received[0]);
     $this->assertContains('Testing...123', $received[0]);
 }
开发者ID:alvarobfdev,项目名称:applog,代码行数:20,代码来源:PhpStreamRequestFactoryTest.php

示例11: finishUpload

 /**
  * Perform the file upload operation.
  *
  * @param  null
  * @return void
  */
 public function finishUpload($requiredHeaders = array())
 {
     $parameters = $this->getParameters();
     if (isset($parameters['_requiredHeaders'])) {
         $requiredHeaders = $parameters['_requiredHeaders'];
     }
     $client = new Client();
     $request = $client->put($parameters['_uploadURL'], $requiredHeaders, fopen($parameters['path'], 'r'));
     $response = $request->send();
     unset($parameters['path']);
     $this->setParameters($parameters);
 }
开发者ID:tvpsoft,项目名称:laravel-kinvey,代码行数:18,代码来源:KinveyFileResponse.php

示例12: send

 public function send(Postmaster_TransportModel $model)
 {
     if (!empty($this->settings->url)) {
         $headers = $this->settings->headers;
         try {
             $client = new Client();
             switch ($this->settings->action) {
                 case 'get':
                     $request = $client->get($this->settings->url, $headers);
                     $query = $request->getQuery();
                     foreach ($this->settings->postVars as $var) {
                         $query->add($var['name'], $var['value']);
                     }
                     break;
                 case 'post':
                     $request = $client->post($this->settings->url, $this->settings->getHeaders(), $this->settings->getRequestVars());
                     break;
                 case 'put':
                     $request = $client->put($this->settings->url, $this->settings->getHeaders(), $this->settings->getRequestVars());
                     break;
                 case 'delete':
                     $request = $client->delete($this->settings->url, $this->settings->getHeaders());
                     break;
             }
             $response = $request->send();
             $model->addData('responseString', (string) $response->getBody());
             $model->addData('responseJson', json_decode($model->getData('responseString')));
             return $this->success($model);
         } catch (ClientErrorResponseException $e) {
             $response = (string) $e->getResponse()->getBody();
             $json = json_decode($response);
             $model->addData('responseString', $response);
             if (is_object($json) && isset($json->errors)) {
                 if (!is_array($json->errors)) {
                     $json->errors = (array) $json->errors;
                 }
                 $model->addData('responseJson', $json);
                 return $this->failed($model, 400, $json->errors);
             } else {
                 $model->addData('responseJson', array($response));
                 return $this->failed($model, 400, array($response));
             }
         } catch (\Exception $e) {
             $error = $e->getMessage();
             $json = !is_array($error) ? array('title' => $error) : $error;
             $model->addData('responseString', $error);
             $model->addData('responseJson', $json);
             return $this->failed($model, 400, $json);
         }
     }
     return $this->failed($model, 400, array(\Craft::t('The ping url is empty.')));
 }
开发者ID:codeforamerica,项目名称:oakland-beta,代码行数:52,代码来源:HttpRequestService.php

示例13: put

 /**
  * Performs an HTTP PUT on a URI. The result can be read from
  * $this->response* variables.
  *
  * @param string|null $uri
  * @param mixed $payload
  * @param string $content_type
  * @param string $accept_type
  * @param array $custom_headers
  * @param array $options
  */
 public function put($uri = null, $payload = '', $content_type = 'application/json; charset=utf-8', $accept_type = 'application/json; charset=utf-8', array $custom_headers = array(), array $options = array())
 {
     self::preparePayload($content_type, $payload);
     $headers = array('accept' => $accept_type, 'content-type' => $content_type);
     foreach ($custom_headers as $key => $value) {
         $headers[strtolower($key)] = $value;
     }
     if (strlen($payload) == 0) {
         $headers['content-type'] = '';
     }
     $request = $this->client->put($uri, $headers, $payload, $options);
     $this->exec($request);
 }
开发者ID:nevetS,项目名称:flame,代码行数:24,代码来源:APIObject.php

示例14: makeRequest

 /**
  * {@inheritdoc}
  */
 public function makeRequest()
 {
     $json = $this->serializer->serialize($this->data, 'json');
     $client = new Client();
     $request = $client->put($this->url, array(), $json);
     $request->setHeader('Content-Type', 'application/json');
     $request->setHeader('Content-Length', strlen($json));
     $request->addHeader('Accept', 'application/json');
     $response = $request->send();
     if (!in_array($response->getStatusCode(), array(200, 201, 100))) {
         throw new \ErrorException($response->getMessage());
     }
     $responseObject = $this->serializer->deserialize($response->getBody(true), get_class($this->data), 'json');
     return $responseObject;
 }
开发者ID:adezandee,项目名称:shopify-bundle,代码行数:18,代码来源:PutJson.php

示例15: testHasHelpfulStaticFactoryMethod

 public function testHasHelpfulStaticFactoryMethod()
 {
     $s = fopen('php://temp', 'r+');
     $client = new Client();
     $client->addSubscriber(LogPlugin::getDebugPlugin(true, $s));
     $request = $client->put('http://foo.com', array('Content-Type' => 'Foo'), 'Bar');
     $request->setresponse(new Response(200), true);
     $request->send();
     rewind($s);
     $contents = stream_get_contents($s);
     $this->assertContains('# Request:', $contents);
     $this->assertContainsIns('PUT / HTTP/1.1', $contents);
     $this->assertContains('# Response:', $contents);
     $this->assertContainsIns('HTTP/1.1 200 OK', $contents);
     $this->assertContains('# Errors:', $contents);
 }
开发者ID:Frinstio,项目名称:AlfredWorkflow.com,代码行数:16,代码来源:LogPluginTest.php


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