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


PHP curl::getContent方法代码示例

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


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

示例1: getFares

 function getFares()
 {
     $this->first_timestamp = $this->getTimestampWithoutTime(time() + $this->days_offset * 24 * 60 * 60);
     $this->last_timestamp = $this->first_timestamp + $this->days_to_check * 24 * 60 * 60;
     $last_request_time = 0;
     echo "IMPORT SESSION ID: " . $this->session_id . $this->nl;
     echo "OFFSET DAYS: " . $this->days_offset . $this->nl;
     echo "DAYS TO CHECK: " . $this->days_to_check . $this->nl;
     echo "START DATE: " . date("d-m-Y", $this->first_timestamp) . $this->nl;
     echo "END DATE: " . date("d-m-Y", $this->last_timestamp) . $this->nl;
     echo "REMOVING OLD RAW FARES" . $this->nl;
     $this->truncateTable('ryan_raw');
     foreach ($this->trips as $trip) {
         $this->fares = array();
         $Origin = $trip[0];
         $Destination = $trip[1];
         echo "TRIP {$Origin} --> {$Destination} " . $this->nl;
         for ($i = $this->first_timestamp; $i <= $this->last_timestamp; $i = $i + $this->FlexDaysOut * 24 * 60 * 60) {
             echo "CURRENT DATE PROCESSING: " . date("d-m-Y", $i) . $this->nl;
             //GOOD BOY
             $time_since_last_request = microtime(TRUE) - $last_request_time;
             if ($time_since_last_request < $this->wait_before_next_page_request) {
                 usleep(($this->wait_before_next_page_request - $time_since_last_request) * 1000000);
             }
             $last_request_time = microtime(TRUE);
             $DateOut = date("Y-m-d", $i);
             $url = $this->url . "&Origin={$Origin}&Destination={$Destination}&DateOut={$DateOut}&FlexDaysOut={$this->FlexDaysOut}";
             $curl_obj = new curl();
             $curl_obj->setRandomUserAgent();
             $ret = $curl_obj->getContent($url);
             if ($ret['errno'] != 0) {
                 echo "AN ERROR HAS OCCURRED DURING CURL: " . $ret['errno'] . " - " . $ret['error'] . " - " . $url . $this->nl . $this->nl;
             }
             if (!$this->decodeJson($ret['content'])) {
                 echo "AN ERROR HAS OCCURRED DURING JSON DECODE: " . json_last_error() . " - " . json_last_error_msg() . $this->nl . $this->nl;
             }
             if (!$this->storeFaresInArray($ret['content'])) {
                 echo "AN ERROR HAS OCCURRED DURING FARES STORING: " . $this->last_error . $this->nl . $this->nl;
             }
         }
         //for each group of days until the end of the period
         $this->fares['metadata']['Origin'] = $Origin;
         $this->fares['metadata']['Destination'] = $Destination;
         $this->fares['metadata']['ts'] = time();
         echo "SAVING TRIP FARES TO DB" . $this->nl;
         $this->storeFaresInDB();
         echo "TRIP PROCESSED" . $this->nl;
         $this->fares = NULL;
         unset($this->fares);
     }
     //for each trip
     echo "UPDATING DEPARTURES INFORMATION" . $this->nl;
     $this->updateFaresDeparturesInfo();
     echo "UPDATING FARES TO NUMBERS" . $this->nl;
     $this->updateFaresValuesToNumbers();
     echo "UPDATING TIMESTAMPS" . $this->nl;
     $this->updateTimestamps();
     echo "REMOVING OLD TRIPS" . $this->nl;
     $this->removeOldTrips();
     echo "REMOVING OLD AGGREGATED DATA" . $this->nl;
     $this->truncateTable("ryan_data");
     echo "GENERATING NEW AGGREGATED DATA" . $this->nl;
     $this->aggregateData();
     echo "PROCESS COMPLETED" . $this->nl . $this->nl;
 }
开发者ID:flevanti,项目名称:ryan,代码行数:65,代码来源:get_ryan_quotes.class.php


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