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


PHP Client::send方法代码示例

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


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

示例1: command

 /**
  * @param string $relation
  * @param array  $parameters
  * @throws ServiceUnavailableHttpException
  * @return Navigator|mixed
  */
 public function command($relation, array $parameters = [], $files = [])
 {
     $templatedUrl = $this->getRelation($relation);
     // expand template url + remove templated params from parameters
     $url = $this->renderUri($templatedUrl, $parameters);
     $templatedParameters = $this->uriTemplater->extract($templatedUrl, $url);
     $parameters = array_diff_key($parameters, $templatedParameters);
     try {
         $headers = [];
         if (!$files) {
             $headers = ['Content-Type' => 'application/json'];
             $parameters = json_encode($parameters);
         }
         $request = $this->guzzleClient->post($url, $headers, $parameters);
         $request->addPostFiles($files);
         $command = $this->guzzleClient->send($request);
     } catch (ClientErrorResponseException $e) {
         throw $e;
     }
     switch ($command->getContentType()) {
         case 'application/hal+json':
             $response = new Navigator($command->json());
             break;
         case 'application/json':
             $response = $command->json();
             break;
         default:
             $response = $command->getBody(true);
             break;
     }
     return $response;
 }
开发者ID:ArDeveloppement,项目名称:HALRestClient,代码行数:38,代码来源:Client.php

示例2: fetch

/**
 * Created by PhpStorm.
 * User: WhiteBlue
 * Date: 15/7/8
 * Time: 下午10:11
 */
function fetch()
{
    $client = new Client();
    $request = new Request('GET', 'http://api.bilibili.cn/index');
    $response = $client->send($request, ['timeout' => 2]);
    $json = json_decode($response->getBody());
    $count = 0;
    foreach ($json as $type => $value) {
        $sort = Sort::where('type', '=', $type)->first();
        if ($sort != null) {
            foreach ($value as $id => $content) {
                if (is_object($content)) {
                    if (Save::where('aid', '=', $content->aid)->first() == null) {
                        $save = new Save();
                        $save->aid = $content->aid;
                        $save->title = $content->title;
                        if (strlen($content->description) > 70) {
                            $save->content = mb_substr($content->description, 0, 70, 'utf-8') . '....';
                        } else {
                            $save->content = $content->description;
                        }
                        $save->href = 'http://www.bilibili.com/video/AV' . $content->aid;
                        $save->img = $content->pic;
                        $sort->saves()->save($save);
                        $count++;
                        $sort->update = date('Y:m:d');
                        $sort->save();
                    }
                }
            }
        }
    }
    event(new UpdateEvent());
    return $count;
}
开发者ID:bajian,项目名称:BiliPusher,代码行数:41,代码来源:fetch.php

示例3: send

    /**
     * @param EntityEnclosingRequest|EntityEnclosingRequest[]
     * @return array|\Guzzle\Http\Message\Response
     * @throws \Exception
     * @throws \Guzzle\Common\Exception\ExceptionCollection
     * @throws mixed
     */
    public function send($requests)
    {
        if ( is_array($requests) && count($requests) > 1 )
        {
            \eZDebug::writeError( 'Should not receive multiple guzzle requests', __CLASS__.'::'.__METHOD__ );
            return parent::send($requests);
        }

        /* @var $request EntityEnclosingRequest */
        $request = is_array($requests) ? $requests[0] : $requests;

        if ( $request->getMethod() !== 'POST' )
        {
            \eZDebug::writeNotice( 'Not POST method used ('.$request->getMethod().'). Falling back to default Guzzle behaviour' );
            return parent::send($requests);
        }

        return GuzzleCurlHelper::sendRequest( $request );

    }
开发者ID:sushilbshinde,项目名称:ezpublish-study,代码行数:27,代码来源:GuzzleClientBase.php

示例4: send

 /**
  * {@inheritdoc}
  * @throws \Aws\Common\Exception\TransferException
  */
 public function send($requests)
 {
     try {
         return parent::send($requests);
     } catch (CurlException $e) {
         $wrapped = new TransferException($e->getMessage(), null, $e);
         $wrapped->setCurlHandle($e->getCurlHandle())->setCurlInfo($e->getCurlInfo())->setError($e->getError(), $e->getErrorNo())->setRequest($e->getRequest());
         throw $wrapped;
     }
 }
开发者ID:risyasin,项目名称:webpagetest,代码行数:14,代码来源:AbstractClient.php


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