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


PHP ClientInterface::post方法代码示例

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


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

示例1: post

 /**
  * {@inheritdoc}
  */
 public function post($url, array $headers = array(), $content = '')
 {
     $headers['content-type'] = 'application/json';
     $request = $this->client->post($url, $headers, $content);
     $this->response = $request->send();
     return $this->response->getBody(true);
 }
开发者ID:BAY-A,项目名称:Gravity-Forms-DigitalOcean,代码行数:10,代码来源:GuzzleAdapter.php

示例2: postContent

 /**
  * {@inheritdoc}
  */
 public function postContent($url, array $headers = array(), array $content = array(), array $files = array())
 {
     $request = $this->client->post($url, $headers, $content);
     foreach ($files as $key => $file) {
         $request->addPostFile($key, $file);
     }
     return $this->sendRequest($request);
 }
开发者ID:widop,项目名称:http-adapter,代码行数:11,代码来源:GuzzleHttpAdapter.php

示例3: track

 public function track($trackingNumber)
 {
     try {
         $response = $this->httpClient->post($this->url, array(), array('API' => 'TrackV2', 'XML' => $this->createTrackRequestXml($trackingNumber)))->send();
     } catch (HttpException $e) {
         throw Exception::createFromHttpException($e);
     }
     return $this->parseTrackResponse($response->getBody(true), $trackingNumber);
 }
开发者ID:hautelook,项目名称:shipment-tracking,代码行数:9,代码来源:UspsProvider.php

示例4: track

 public function track($trackingNumber)
 {
     $body = $this->createAuthenticationXml() . $this->createTrackXml($trackingNumber);
     try {
         $response = $this->httpClient->post($this->url, array(), $body)->send();
     } catch (HttpException $e) {
         throw Exception::createFromHttpException($e);
     }
     return $this->parse($response->getBody(true));
 }
开发者ID:adrienbrault,项目名称:shipment-tracking,代码行数:10,代码来源:UpsProvider.php

示例5: call

 public function call($wrappedClass, $method, array $params = array())
 {
     $request = $this->client->post(sprintf('/%s/%s', str_replace('\\', '/', $wrappedClass), $method), $params);
     $auth = $this->getAuthConfig($this->auth);
     if ($auth) {
         $request->setAuth($auth['login'], $auth['pass'], $auth['type']);
     }
     $response = $request->send();
     return $response->getBody();
 }
开发者ID:evaneos,项目名称:dic-it,代码行数:10,代码来源:RestAdapter.php

示例6: post

 /**
  * {@inheritdoc}
  */
 public function post($url, $content = '')
 {
     $request = $this->client->post($url, [], $content);
     try {
         $this->response = $request->send();
     } catch (RequestException $e) {
         $this->response = $e->getResponse();
         $this->handleError();
     }
     return $this->response->getBody(true);
 }
开发者ID:skaisser,项目名称:organizze,代码行数:14,代码来源:GuzzleAdapter.php

示例7: format

 /**
  * {@inheritDoc}
  */
 public function format($string)
 {
     $request = $this->client->post('markdown', null, json_encode(array('text' => $string)));
     try {
         $response = $request->send();
     } catch (BadResponseException $e) {
         $response = $e->getResponse();
         $json = $response->json();
         throw new RuntimeException(sprintf('Request to Github failed: %s [%d]', $json['message'], $response->getStatusCode()));
     }
     return $response->getBody(true);
 }
开发者ID:fabricius,项目名称:fabricius,代码行数:15,代码来源:MarkdownGithubHandler.php

示例8: buildRequestObject

 /**
  * @param array $postData
  * @return \Guzzle\Http\Message\EntityEnclosingRequestInterface|\Guzzle\Http\Message\RequestInterface
  * @throws Exceptions\BadServiceException
  * @throws Exceptions\AppNexusAPIException
  */
 private function buildRequestObject(array $postData = array())
 {
     $where = $this->where;
     if (isset($where['since'])) {
         if (!$this->getServiceObject($this->getService())->supportsSince()) {
             throw new BadServiceException(sprintf("[%s] does not support `since()`", $this->getService()));
         }
         switch ($this->getService()) {
             case self::SERVICE_LANGUAGE:
                 $key = 'min_last_activity';
                 break;
             default:
                 $key = 'min_last_modified';
                 break;
         }
         $where[$key] = $where['since'];
         unset($where['since']);
     }
     $uri = sprintf("/%s?%s", $this->getService(), http_build_query($where));
     switch ($this->getServiceObject($this->getService())->getRequestVerb()) {
         case 'get':
             return $this->client->get($uri, array('Authorization' => $this->token));
             break;
         case 'post':
             return $this->client->post($uri, array('Authorization' => $this->token), json_encode($postData));
             break;
         default:
             throw new AppNexusAPIException(sprintf("Unknown verb [%s]", $this->getServiceObject($this->getService())->getRequestVerb()));
     }
 }
开发者ID:swco,项目名称:appnexusapi,代码行数:36,代码来源:Request.php

示例9: postJson

 /**
  * {@inheritDoc}
  */
 public function postJson($path, $postBody, array $parameters = array(), array $headers = array())
 {
     $parameters = $this->buildQueryParameters($parameters);
     $request = $this->client->post($path, $headers, null, $parameters);
     $request->setBody($postBody, 'application/json');
     return $this->request($request);
 }
开发者ID:n10ty,项目名称:api,代码行数:10,代码来源:HttpClient.php

示例10: updateTranslation

 /**
  * {@inheritdoc}
  */
 public function updateTranslation($masterfile, $lang, $filePath)
 {
     $url = $this->getApiUrl('translation', array('master-file-name' => $masterfile, 'language-tag' => $lang));
     $response = $this->httpClient->post($url)->addPostFile('file', $filePath)->send();
     if (!$response->isSuccessful()) {
         throw new RuntimeException('Something went wrong dialing with the api server: ' . $response->getBody());
     }
     return $response->getBody(true);
 }
开发者ID:nicmart,项目名称:getlocalization,代码行数:12,代码来源:Client.php

示例11: enableOauthAuthentication

 public function enableOauthAuthentication($key, $secret, $accessToken = null, $code = null)
 {
     $this->key = $key;
     $this->secret = $secret;
     $this->accessToken = $accessToken;
     $this->code = $code;
     if (!$accessToken && !$code) {
         throw new InvalidArgumentException(sprintf("No OAuth code or access token given, please visit %s to generate a new code", "https://www.dropbox.com/1/oauth2/authorize?response_type=code&client_id={$key}"));
     } elseif (!$accessToken && $code) {
         $request = $this->client->post('oauth2/token', array(), array('code' => $this->code, 'grant_type' => 'authorization_code', 'client_id' => $this->key, 'client_secret' => $this->secret));
         try {
             $response = $request->send();
         } catch (ClientErrorResponseException $e) {
             $this->handleBadResponseExceptions($e);
         }
         $token = $response->json();
         $this->accessToken = $token['access_token'];
     }
     $this->client->setDefaultOption('request.options/headers/Authorization', 'Bearer ' . $this->accessToken);
 }
开发者ID:fabricius,项目名称:fabricius,代码行数:20,代码来源:DropboxLoader.php

示例12: send

 /**
  * {@inheritdoc}
  */
 public function send(MessageInterface $message)
 {
     // Validate we have everything we need
     foreach (array('token', 'room', 'from') as $variable) {
         if (empty($this->{$variable})) {
             throw new InvalidArgumentException("Invalid `{$variable}`");
         }
     }
     // Build up the data we are sending to Hipchat
     $data = array('room_id' => $this->getRoom(), 'from' => $this->getFrom(), 'message' => $message->getMessage(), 'message_format' => $message->getMessageFormat(), 'notify' => $message->getNotification(), 'color' => $message->getBackgroundColor(), 'format' => 'json');
     $data = http_build_query($data, '', '&');
     return $this->http->post($this->getUri(), $this->getHeaders(), $data)->send();
 }
开发者ID:rcrowe,项目名称:hippy,代码行数:16,代码来源:Guzzle.php

示例13: refreshToken

 private function refreshToken()
 {
     $request = $this->client->post('https://accounts.google.com/o/oauth2/token', array(), array('client_id' => $this->clientId, 'client_secret' => $this->clientSecret, 'refresh_token' => $this->refreshToken, 'grant_type' => 'refresh_token'));
     try {
         $response = $request->send();
     } catch (ClientErrorResponseException $e) {
         $this->handleBadResponseExceptions($e);
     }
     $token = $response->json();
     if (!isset($token['access_token'])) {
         throw new RuntimeException('Invalid token response received from Google Drive');
     }
     $this->enableOAuth2Authentication($this->clientId, $this->clientSecret, $token['access_token'], $this->refreshToken);
 }
开发者ID:fabricius,项目名称:fabricius,代码行数:14,代码来源:GoogleDriveLoader.php

示例14: getToken

 /**
  * @param AccessToken $token
  * @return AcccessToken
  */
 public function getToken(AccessToken $token = null)
 {
     if ($token && $token->getRefreshToken()) {
         $this->body['grant_type'] = 'refresh_token';
         $this->body['refresh_token'] = $token->getRefreshToken();
     } else {
         $this->buildBody();
     }
     $request = $this->client->post($this->tokenRequestPath, $this->headers, $this->body);
     $response = $request->send();
     $data = $response->json();
     $refreshToken = isset($data['data']['refresh_token']) ?: '';
     return new AccessToken($data['data']['access_token'], $refreshToken, $data['data']['expires_in']);
 }
开发者ID:careerbuilder,项目名称:php-oauth,代码行数:18,代码来源:Flow.php

示例15: post

 /**
  * {@inheritdoc}
  */
 public function post($url, $content = '')
 {
     $request = $this->client->post($url);
     if (is_array($content)) {
         $request->setBody(json_encode($content), 'application/json');
     } else {
         $request->setBody($content);
     }
     try {
         $this->response = $request->send();
     } catch (RequestException $e) {
         $this->response = $e->getResponse();
         $this->handleError();
     }
     return $this->response->getBody(true);
 }
开发者ID:skaisser,项目名称:upcloud,代码行数:19,代码来源:GuzzleAdapter.php


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