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


PHP Kurogo::KurogoUserAgent方法代码示例

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


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

示例1: streamContextOpts

 protected function streamContextOpts($args)
 {
     $streamContextOpts = array('http' => array('user_agent' => Kurogo::KurogoUserAgent()));
     if (isset($args['HTTP_PROXY_URL'])) {
         $streamContextOpts['http'] = array('proxy' => $args['HTTP_PROXY_URL'], 'request_fulluri' => TRUE);
     }
     if (isset($args['HTTPS_PROXY_URL'])) {
         $streamContextOpts['https'] = array('proxy' => $args['HTTPS_PROXY_URL'], 'request_fulluri' => TRUE);
     }
     return $streamContextOpts;
 }
开发者ID:nncsang,项目名称:Kurogo,代码行数:11,代码来源:URLDataRetriever.php

示例2: detectDeviceExternal

 protected function detectDeviceExternal($user_agent)
 {
     if (!$user_agent) {
         return;
     }
     // see if the server has cached the results from the the device detection server
     try {
         $cache = new DiskCache($this->cacheFolder(), $this->cacheLifetime(), TRUE);
     } catch (KurogoDataException $e) {
         $cache = null;
     }
     $cacheFilename = md5($user_agent);
     if ($cache && $cache->isFresh($cacheFilename)) {
         $json = $cache->read($cacheFilename);
         Kurogo::log(LOG_INFO, "Using cached data for external device detection", 'deviceDetection');
     } else {
         $query = http_build_query(array('user-agent' => $user_agent, 'version' => $this->version));
         $url = Kurogo::getSiteVar('MOBI_SERVICE_URL') . '?' . $query;
         Kurogo::log(LOG_INFO, "Detecting device using external device detection: {$url}", 'deviceDetection');
         $timeout = Kurogo::getOptionalSiteVar('MOBI_SERVICE_EXTERNAL_TIMEOUT', 5);
         $context = stream_context_create(array('http' => array('timeout' => $timeout, 'user_agent' => Kurogo::KurogoUserAgent())));
         $json = @file_get_contents($url, false, $context);
         if (false === $json) {
             return $this->detectDeviceInternal($user_agent);
         }
         $test = json_decode($json, true);
         // make sure the response is valid
         if ($cache) {
             if ($json && isset($test['pagetype'], $test['platform'])) {
                 $cache->write($json, $cacheFilename);
             } else {
                 Kurogo::log(LOG_WARNING, "Error receiving device detection data from {$url}.  Reading expired cache.", 'deviceDetection');
                 $json = $cache->read($cacheFilename);
             }
         }
     }
     $data = json_decode($json, true);
     // fix values when using old version
     if ($this->version == 1) {
         switch (strtolower($data['pagetype'])) {
             case 'basic':
                 if ($data['platform'] == 'computer' || $data['platform'] == 'spider') {
                     $data['pagetype'] = 'compliant';
                 } else {
                     if ($data['platform'] == 'bbplus') {
                         $data['pagetype'] = 'compliant';
                     } else {
                         $data['pagetype'] = 'basic';
                     }
                 }
                 break;
             case 'touch':
                 if ($data['platform'] == 'blackberry') {
                     $data['pagetype'] = 'compliant';
                     // Storm, Storm 2
                 } else {
                     if ($data['platform'] == 'winphone7') {
                         $data['pagetype'] = 'compliant';
                         // Windows Phone 7
                     } else {
                         $data['pagetype'] = 'touch';
                     }
                 }
                 break;
             case 'compliant':
             case 'webkit':
             default:
                 $data['pagetype'] = 'compliant';
                 break;
         }
     }
     return $data;
 }
开发者ID:sponto,项目名称:Kurogo-Mobile-Web,代码行数:73,代码来源:DeviceClassifier.php


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