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


PHP Filesystem::getExternUrlContent方法代码示例

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


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

示例1: fetchElevationFor

 /**
  * Fetch elevation
  * @param array $latitudes
  * @param array $longitudes
  * @return array
  * @throws \RuntimeException
  */
 protected function fetchElevationFor(array $latitudes, array $longitudes)
 {
     $latitudeString = implode(',', $latitudes);
     $longitudeString = implode(',', $longitudes);
     $url = 'http://api.geonames.org/srtm3JSON?lats=' . $latitudeString . '&lngs=' . $longitudeString . '&username=' . $this->USERNAME;
     $response = json_decode(\Filesystem::getExternUrlContent($url), true);
     if (is_null($response) || !isset($response['geonames']) || !is_array($response['geonames'])) {
         throw new \RuntimeException('Geonames returned malformed code.');
     }
     $elevationData = array();
     $responseLength = count($response['geonames']);
     for ($i = 0; $i < $responseLength; $i++) {
         $elevationData[] = (int) $response['geonames'][$i]['srtm3'];
     }
     return $elevationData;
 }
开发者ID:guancio,项目名称:Runalyze,代码行数:23,代码来源:Geonames.php

示例2: fetchElevationFor

 /**
  * Fetch elevation
  * @param array $latitudes
  * @param array $longitudes
  * @return array
  */
 protected function fetchElevationFor(array $latitudes, array $longitudes)
 {
     $numberOfCoordinates = count($latitudes);
     $coordinatesString = '';
     for ($i = 0; $i < $numberOfCoordinates; $i++) {
         $coordinatesString .= $latitudes[$i] . ',' . $longitudes[$i] . '|';
     }
     $url = 'http://maps.googleapis.com/maps/api/elevation/json?locations=' . substr($coordinatesString, 0, -1) . '&sensor=false';
     $response = json_decode(\Filesystem::getExternUrlContent($url), true);
     if (is_null($response) || !is_array($response) || !isset($response['results']) || !isset($response['results'][0]['elevation'])) {
         throw new \RuntimeException('GoogleMaps returned malformed code.');
     }
     $elevationData = array();
     $responseLength = count($response['results']);
     for ($i = 0; $i < $responseLength; $i++) {
         $elevationData[] = (int) $response['results'][$i]['elevation'];
     }
     return $elevationData;
 }
开发者ID:rob-st,项目名称:Runalyze,代码行数:25,代码来源:GoogleMaps.php

示例3: fetchElevationFor

 /**
  * Fetch elevation
  * @param array $latitudes
  * @param array $longitudes
  * @return array
  * @throws \RuntimeException
  */
 protected function fetchElevationFor(array $latitudes, array $longitudes)
 {
     $numberOfCoordinates = count($latitudes);
     $coordinatesArray = array();
     for ($i = 0; $i < $numberOfCoordinates; $i++) {
         $coordinatesArray[] = array($latitudes[$i], $longitudes[$i]);
     }
     $coordinatesString = json_encode($coordinatesArray);
     $url = 'http://www.datasciencetoolkit.org/coordinates2statistics/' . $coordinatesString . '?statistics=elevation';
     $response = json_decode(\Filesystem::getExternUrlContent($url), true);
     if (is_null($response) || !is_array($response) || !isset($response[0]['statistics']) || !isset($response[0]['statistics']['elevation'])) {
         throw new \RuntimeException('DataScienceToolkit returned malformed code.');
     }
     $elevationData = array();
     $responseLength = count($response);
     for ($i = 0; $i < $responseLength; $i++) {
         $elevationData[] = (int) $response[$i]['statistics']['elevation']['value'];
     }
     return $elevationData;
 }
开发者ID:n0rthface,项目名称:Runalyze,代码行数:27,代码来源:DataScienceToolkit.php

示例4: setFromURL

 /**
  * Set from url
  * @param string $url
  * @param string $cacheKey [optional] if true result will be cached
  */
 public function setFromURL($url, $cacheKey = false)
 {
     if ($cacheKey !== false) {
         $this->Result = Cache::get($cacheKey, 1);
         if ($this->Result != null) {
             return;
         } else {
             $this->Result = array();
         }
     }
     if (defined('OPENWEATHERMAP_API_KEY') && strlen(OPENWEATHERMAP_API_KEY)) {
         $url .= '&APPID=' . OPENWEATHERMAP_API_KEY;
     }
     $this->setFromJSON(\Filesystem::getExternUrlContent($url));
     if ($cacheKey !== false) {
         Cache::set($cacheKey, $this->Result, 7200, 1);
     }
 }
开发者ID:aschix,项目名称:Runalyze,代码行数:23,代码来源:Openweathermap.php


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