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


PHP Request::timeout方法代码示例

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


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

示例1: send

 public function send(Request $r)
 {
     try {
         Unirest::timeout($this->timeout);
         $http = Unirest::{$r->method}($r->url, $r->headers, $r->body);
         $response = new Response((string) $http->raw_body);
         $response->statusCode = (string) $http->code;
         $response->json = json_decode((string) $response, true);
     } catch (\Exception $e) {
         $response = new Response($e->getMessage());
         $response->statusCode = 500;
     }
     $this->logger->logHttpCommunication($r, $response);
     return $response;
 }
开发者ID:sojki,项目名称:payments-sdk-php,代码行数:15,代码来源:JsonBrowser.php

示例2: avaliable

 /**
  * Checks if the daemon is running.
  *
  * @param string $ip
  * @param int $port
  * @param int $timeout
  * @return bool
  */
 public function avaliable($ip, $port = 5656, $timeout = 3)
 {
     Unirest\Request::timeout($timeout);
     try {
         Unirest\Request::get("https://" . $ip . ":" . $port);
         return true;
     } catch (\Exception $e) {
         return false;
     }
 }
开发者ID:PhenixH,项目名称:PufferPanel,代码行数:18,代码来源:daemon.php

示例3: online

 /**
  * Gets the status of any specified server given an IP address.
  *
  * @return bool Returns an true if server is on, false if off or invalid data was recieved.
  */
 public function online()
 {
     if (!$this->server || !$this->node) {
         return false;
     }
     try {
         Unirest\Request::timeout(1);
         $request = Unirest\Request::get("https://" . $this->node->fqdn . ":" . $this->node->daemon_listen . "/server", array('X-Access-Token' => $this->node->daemon_secret, 'X-Access-Server' => $this->server->hash));
         /*
          * Valid Data was Returned
          */
         if (!isset($request->body->status) || $request->body->status == 0) {
             return false;
         }
         $this->query_data = $request->body;
         return true;
     } catch (\Exception $e) {
         return false;
     }
 }
开发者ID:ByteKing,项目名称:Main,代码行数:25,代码来源:daemon.php

示例4:

<?php

/*
 * Include composer and configuration files
 */
require_once BASE_DIR . 'vendor/autoload.php';
\Unirest\Request::verifyPeer(false);
\Unirest\Request::timeout(5);
/*
* Include required files
*/
require_once SRC_DIR . 'core/components/authentication.php';
require_once SRC_DIR . 'core/components/errorhandler.php';
require_once SRC_DIR . 'core/components/functions.php';
require_once SRC_DIR . 'core/components/daemon.php';
require_once SRC_DIR . 'core/components/page.php';
require_once SRC_DIR . 'core/components/url.php';
require_once SRC_DIR . 'core/config/configinterface.php';
require_once SRC_DIR . 'core/config/jsonconfig.php';
require_once SRC_DIR . 'core/config/databaseconfig.php';
require_once SRC_DIR . 'core/config/inmemdatabaseconfig.php';
require_once SRC_DIR . 'core/config.php';
require_once SRC_DIR . 'core/databasemanager.php';
require_once SRC_DIR . 'core/authentication.php';
require_once SRC_DIR . 'core/email.php';
require_once SRC_DIR . 'core/files.php';
require_once SRC_DIR . 'core/user.php';
require_once SRC_DIR . 'core/language.php';
require_once SRC_DIR . 'core/log.php';
require_once SRC_DIR . 'core/permissions.php';
require_once SRC_DIR . 'core/server.php';
开发者ID:ByteKing,项目名称:Main,代码行数:31,代码来源:autoloader.php

示例5: getItems

 public function getItems($options)
 {
     $headers = array('Cookie' => $this->webCookies, 'Timeout' => Unirest\Request::timeout(5));
     $response = Unirest\Request::get('https://steamcommunity.com/trade/' . $options['tradeId'] . '/receipt/', $headers);
     if ($response->code != 200) {
         die('Error get items. Server response code: ' . $response->code);
     }
     $body = $response->body;
     preg_match('/(var oItem;[\\s\\S]*)<\\/script>/', $body, $matches);
     if (!$matches) {
         die('Error get items: no session');
     }
     $temp = str_replace(array("\r", "\n"), "", $matches[1]);
     $items = array();
     preg_match_all('/oItem = {(.*?)};/', $temp, $matches);
     foreach ($matches[0] as $key => $value) {
         $value = rtrim(str_replace('oItem = ', '', $value), ';');
         $items[] = json_decode($value, 1);
     }
     return $items;
 }
开发者ID:stefanstankovic,项目名称:CSGO_project,代码行数:21,代码来源:SteamTrade.php

示例6: testTimeoutFail

 /**
  * @expectedException \Unirest\Exception
  */
 public function testTimeoutFail()
 {
     Request::timeout(1);
     Request::get('http://mockbin.com/delay/1000');
     Request::timeout(null);
     // Cleaning timeout for the other tests
 }
开发者ID:RusinovIG,项目名称:unirest-php,代码行数:10,代码来源:RequestTest.php


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