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


PHP core::curl_get_contents方法代码示例

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


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

示例1: address_coords

 /**
  * get geocode lat/lon points for given address from google
  * 
  * @param string $address
  * @return bool|array false if can't be geocoded, array or geocdoes if successful
  */
 public static function address_coords($address)
 {
     $url = 'http://maps.google.com/maps/api/geocode/json?sensor=false&address=' . rawurlencode($address);
     //try to get the json from the cache
     $coords = Core::cache($url);
     //not cached :(
     if ($coords === NULL) {
         $coords = FALSE;
         //get contents from google
         if ($result = core::curl_get_contents($url)) {
             $result = json_decode($result);
             //not found :()
             if ($result->status != "OK") {
                 $coords = FALSE;
             } else {
                 $coords['lat'] = $result->results[0]->geometry->location->lat;
                 $coords['lon'] = $result->results[0]->geometry->location->lng;
             }
         }
         //save the json
         Core::cache($url, $coords, strtotime('+7 day'));
     }
     return $coords;
 }
开发者ID:kotsios5,项目名称:openclassifieds2,代码行数:30,代码来源:map.php

示例2: action_get_ads_latlgn

 /**
  * get geocode lat/lon points for given address from google
  * 
  * @param string $address
  * @return bool|array false if can't be geocoded, array or geocdoes if successful
  */
 public function action_get_ads_latlgn()
 {
     $ads = new Model_Ad();
     $ads = $ads->where('latitude', 'IS', NULL)->where('longitude', 'IS', NULL)->where('address', 'IS NOT', NULL)->where('address', '!=', '')->find_all();
     foreach ($ads as $ad) {
         $url = 'http://maps.google.com/maps/api/geocode/json?sensor=false&address=' . urlencode($ad->address);
         //get contents from google
         if ($result = core::curl_get_contents($url)) {
             $result = json_decode($result);
             if ($result and $result->status == "OK") {
                 $ad->latitude = $result->results[0]->geometry->location->lat;
                 $ad->longitude = $result->results[0]->geometry->location->lng;
                 try {
                     $ad->save();
                 } catch (Exception $e) {
                     throw HTTP_Exception::factory(500, $e->getMessage());
                 }
             }
         }
     }
     Alert::set(Alert::SUCCESS, __('Successfully imported latitude and longitude info from your ads.'));
     $this->redirect(Route::url('oc-panel', array('controller' => 'import', 'action' => 'csv')));
 }
开发者ID:kleitz,项目名称:openclassifieds2,代码行数:29,代码来源:tools.php

示例3: versions

 /**
  * returns array of last versions from json
  * @return array
  */
 public static function versions()
 {
     return json_decode(core::curl_get_contents('http://open-classifieds.com/files/versions.json?r=' . time()), TRUE);
 }
开发者ID:zhangkom,项目名称:openclassifieds2,代码行数:8,代码来源:install-openclassifieds.php

示例4: download

 public static function download($l)
 {
     $api_url = Kohana::$environment !== Kohana::DEVELOPMENT ? 'market.' . Core::DOMAIN : 'eshop.lo';
     $download_url = 'http://' . $api_url . '/api/download/' . $l . '/?domain=' . parse_url(URL::base(), PHP_URL_HOST);
     $fname = DOCROOT . 'themes/' . $l . '.zip';
     //root folder
     $file_content = core::curl_get_contents($download_url);
     if ($file_content != 'false') {
         // saving zip file to dir.
         file_put_contents($fname, $file_content);
         $zip = new ZipArchive();
         if ($zip_open = $zip->open($fname)) {
             //if theres nothing in that ZIP file...zip corrupted :(
             if ($zip->getNameIndex(0) === FALSE) {
                 return FALSE;
             }
             $theme_name = substr($zip->getNameIndex(0), 0, -1);
             $zip->extractTo(DOCROOT . 'themes/');
             $zip->close();
             unlink($fname);
             return $theme_name;
         }
     }
     return FALSE;
 }
开发者ID:Chinese1904,项目名称:common,代码行数:25,代码来源:theme.php

示例5: action_latest

 /**
  * STEP 1
  * Downloads and extracts latest version
  */
 public function action_latest()
 {
     //save in a session the current version so we can selective update the DB later
     Session::instance()->set('update_from_version', Core::VERSION);
     $versions = core::config('versions');
     //loads OC software version array
     $last_version = key($versions);
     //get latest version
     $download_link = $versions[$last_version]['download'];
     //get latest download link
     $update_src_dir = DOCROOT . 'update';
     // update dir
     $file_name = $update_src_dir . '/' . $last_version . '.zip';
     //full file name
     //check if exists already the download, if does delete
     if (file_exists($file_name)) {
         unlink($file_name);
     }
     //create update dir if doesnt exists
     if (!is_dir($update_src_dir)) {
         mkdir($update_src_dir, 0775);
     }
     //verify we could get the zip file
     $file_content = core::curl_get_contents($download_link);
     if ($file_content == FALSE) {
         Alert::set(Alert::ALERT, __('We had a problem downloading latest version, try later please.'));
         $this->redirect(Route::url('oc-panel', array('controller' => 'update', 'action' => 'index')));
     }
     //Write the file
     file_put_contents($file_name, $file_content);
     //unpack zip
     $zip = new ZipArchive();
     // open zip file, and extract to dir
     if ($zip_open = $zip->open($file_name)) {
         $zip->extractTo($update_src_dir);
         $zip->close();
     } else {
         Alert::set(Alert::ALERT, $file_name . ' ' . __('Zip file failed to extract, please try again.'));
         $this->redirect(Route::url('oc-panel', array('controller' => 'update', 'action' => 'index')));
     }
     //delete downloaded file
     unlink($file_name);
     //move files in different request so more time
     $this->redirect(Route::url('oc-panel', array('controller' => 'update', 'action' => 'files')));
 }
开发者ID:JeffPedro,项目名称:project-garage-sale,代码行数:49,代码来源:update.php


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