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


PHP Client::addSubscriber方法代码示例

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


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

示例1: register

 public function register(Application $app)
 {
     $app['guzzle.base_url'] = '/';
     $app['guzzle.api_version'] = $app->share(function () use($app) {
         return version_compare(Client::VERSION, '6.0.0', '>=') ? 6 : 5;
     });
     if (!isset($app['guzzle.handler_stack'])) {
         $app['guzzle.handler_stack'] = $app->share(function () {
             return HandlerStack::create();
         });
     }
     /** @deprecated Remove when Guzzle 5 support is dropped */
     if (!isset($app['guzzle.plugins'])) {
         $app['guzzle.plugins'] = [];
     }
     // Register a simple Guzzle Client object (requires absolute URLs when guzzle.base_url is unset)
     $app['guzzle.client'] = $app->share(function () use($app) {
         if ($app['guzzle.api_version'] === 5) {
             $options = ['base_url' => $app['guzzle.base_url']];
             $client = new Client($options);
             foreach ($app['guzzle.plugins'] as $plugin) {
                 $client->addSubscriber($plugin);
             }
         } else {
             $options = ['base_uri' => $app['guzzle.base_url'], 'handler' => $app['guzzle.handler_stack']];
             $client = new Client($options);
         }
         return $client;
     });
 }
开发者ID:d-m-,项目名称:bolt,代码行数:30,代码来源:GuzzleServiceProvider.php

示例2: post

 /**
  * Upload post 
  */
 public function post()
 {
     $token = Session::get('token');
     $client = new Client(['base_url' => $this->oauthUrl, 'defaults' => ['auth' => 'oauth']]);
     $oauthConfig = array('consumer_key' => $this->oauthKey, 'consumer_secret' => $this->oauthSecret, 'token' => $token->oauth_token, 'token_secret' => $token->oauth_token_secret);
     $oauth = new Oauth1($oauthConfig);
     $client->getEmitter()->attach($oauth);
     $logger = new Logger('client');
     $logger->pushHandler(new StreamHandler('guzzle.log'));
     $logAdapter = new MonologLogAdapter($logger);
     $logPlugin = new LogPlugin($logAdapter, MessageFormatter::DEBUG_FORMAT);
     $client->addSubscriber($logPlugin);
     $content = file_get_contents(Input::file("inputFileName")->getRealPath());
     try {
         /*
         $r = $client->put($this->oauthRequestImageEndpoint.'?output=json', ['body' => $content ]);
         $imageResult = json_decode($r->getBody());
         $message = "[img]".$imageResult->url."[/img]";
         */
         $forum_id = Config::get('kasgag.forum');
         $title = Input::get("inputTitle");
         $message = '[img]http://kascdn.mooo.com/images/2014/10/12/11_201410120657540167.jpg[/img]';
         $resp = $client->post('thread', ['body' => ['forum_id' => $forum_id, 'title' => $title, 'message' => $message]]);
         // save to DB
         var_dump($resp);
         /*
         $post = json_decode($resp,true);
         $newThreadInfo = new ThreadInfo;
         $newThreadInfo->id = $post['thread_id'];
         $newThreadInfo->title = $title;
         $newThreadInfo->user_id = $token->userid;
         $newThreadInfo->user_name = $token->username;
         $newThreadInfo->page_text = $message;
         $newThreadInfo->save();
         */
     } catch (RequestException $re) {
         echo $re->getRequest() . "\n";
         if ($re->hasResponse()) {
             echo $re->getResponse() . "\n";
         }
     } catch (ClientException $ce) {
         echo $ce->getRequest() . "\n";
         if ($ce->hasResponse()) {
             echo $ce->getResponse() . "\n";
         }
     }
     //return Redirect::to("/");
 }
开发者ID:muhridwan-kk,项目名称:kaskus-gag,代码行数:51,代码来源:HomeController.php

示例3: register

 public function register(Application $app)
 {
     $app['guzzle.base_url'] = '/';
     if (!isset($app['guzzle.plugins'])) {
         $app['guzzle.plugins'] = [];
     }
     // Register a simple Guzzle Client object (requires absolute URLs when guzzle.base_url is unset)
     $app['guzzle.client'] = $app->share(function () use($app) {
         $options = ['base_url' => $app['guzzle.base_url']];
         $client = new Client($options);
         foreach ($app['guzzle.plugins'] as $plugin) {
             $client->addSubscriber($plugin);
         }
         return $client;
     });
 }
开发者ID:atiarda,项目名称:bolt,代码行数:16,代码来源:GuzzleServiceProvider.php

示例4: register

 public function register(Application $app)
 {
     $app['guzzle.base_url'] = '/';
     if (!isset($app['guzzle.plugins'])) {
         $app['guzzle.plugins'] = array();
     }
     /** @deprecated */
     if ($app['deprecated.php']) {
         return $this->compat($app);
     }
     // Register a simple Guzzle Client object (requires absolute URLs when guzzle.base_url is unset)
     $app['guzzle.client'] = $app->share(function () use($app) {
         $options = array('base_url' => $app['guzzle.base_url']);
         $client = new Client($options);
         foreach ($app['guzzle.plugins'] as $plugin) {
             $client->addSubscriber($plugin);
         }
         return $client;
     });
 }
开发者ID:aleksabp,项目名称:bolt,代码行数:20,代码来源:GuzzleServiceProvider.php


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