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


PHP SJB_HelperFunctions::getUrlContentByCurl方法代码示例

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


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

示例1: current

 public function current()
 {
     $listing_structure = array();
     $info = current($this->array);
     if (is_numeric($info)) {
         $sid = $info;
         $cache = SJB_Cache::getInstance();
         $cacheID = md5('ListingIterator::SJB_ListingManager::getObjectBySID' . $sid);
         if ($cache->test($cacheID)) {
             $listing = $cache->load($cacheID);
         } else {
             $listing = SJB_ListingManager::getObjectBySID($sid);
             $cache->save($listing, $cacheID, array(SJB_Cache::TAG_LISTINGS));
         }
         $listing->addPicturesProperty();
         $cacheId = md5('SJB_ListingTypeManager::getListingTypeIDBySID' . $listing->getListingTypeSID());
         if (SJB_MemoryCache::has($cacheId)) {
             $listing_type = SJB_MemoryCache::get($cacheId);
         } else {
             $listing_type = SJB_ListingTypeManager::getListingTypeIDBySID($listing->getListingTypeSID());
             SJB_MemoryCache::set($cacheId, $listing_type);
         }
         $listing_structure = SJB_ListingManager::createTemplateStructureForListing($listing);
         $listing_structure = SJB_ListingManager::newValueFromSearchCriteria($listing_structure, $this->criteria);
         if ($this->user_logged_in) {
             $listing_structure['saved_listing'] = SJB_SavedListings::getSavedListingsByUserAndListingSid($this->current_user_sid, $listing->getID());
         }
         $listing_structure['activation_date'] = date('Y-m-d H:i:s', strtotime($listing_structure['activation_date']));
         $listing_structure['expiration_date'] = date('Y-m-d H:i:s', strtotime($listing_structure['expiration_date']));
         $listing_structure['listing_url'] = SJB_System::getSystemSettings('SITE_URL') . "/display-" . strtolower($listing_type) . "/" . $listing->getSID() . "/";
         if (isset($listing->details->properties['EmploymentType'])) {
             $employmentInfo = $listing->details->properties['EmploymentType']->type->property_info;
             $employmentTypes = array();
             $employment = explode(",", $employmentInfo['value']);
             foreach ($employmentInfo['list_values'] as $type) {
                 $empType = str_replace(" ", "", $type['caption']);
                 $employmentTypes[$empType] = 0;
                 if (in_array($type['id'], $employment)) {
                     $employmentTypes[$empType] = 1;
                 }
             }
             $listing_structure['myEmploymentType'] = $employmentTypes;
         }
         // GOOGLE MAP SEARCH RESULTS CUSTOMIZATION
         if ($this->view == 'map') {
             $zipCode = $listing_structure['Location']['ZipCode'];
             // get 'latitude' and 'longitude' from zipCode field, if it not set
             $latitude = isset($listing_structure['latitude']) ? $listing_structure['latitude'] : '';
             $longitude = isset($listing_structure['longitude']) ? $listing_structure['longitude'] : '';
             if (!empty($zipCode) && empty($latitude) && empty($longitude)) {
                 $result = SJB_DB::query("SELECT * FROM `locations` WHERE `name` = ?s LIMIT 1", $zipCode);
                 if ($result) {
                     $current_coordinates = array($result[0]['latitude'], $result[0]['longitude']);
                     if (in_array($current_coordinates, self::$coordinates)) {
                         self::$index += 0.0001;
                     }
                     $listing_structure['latitude'] = $result[0]['latitude'] + self::$index;
                     $listing_structure['longitude'] = $result[0]['longitude'] + self::$index;
                     self::$coordinates = array_merge(self::$coordinates, array($current_coordinates));
                 }
             } elseif (!empty($listing_structure['Location']['City']) && !empty($listing_structure['Location']['State']) && !empty($listing_structure['Location']['Country'])) {
                 $address = $listing_structure['Location']['City'] . ', ' . $listing_structure['Location']['State'] . ', ' . $listing_structure['Location']['Country'];
                 $address = urlencode($address);
                 $cache = SJB_Cache::getInstance();
                 $parameters = array('City' => $listing_structure['Location']['City'], 'State' => $listing_structure['Location']['State'], 'Country' => $listing_structure['Location']['Country']);
                 $hash = md5('google_map' . serialize($parameters));
                 $data = $cache->load($hash);
                 if (!$data) {
                     try {
                         $geoCod = SJB_HelperFunctions::getUrlContentByCurl("http://maps.googleapis.com/maps/api/geocode/json?address={$address}&sensor=false");
                         $geoCod = json_decode($geoCod);
                         if ($geoCod->status == 'OK') {
                             $cache->save($geoCod, $hash);
                         }
                     } catch (Exception $e) {
                         $backtrace = SJB_Logger::getBackTrace();
                         SJB_Error::writeToLog(array(array('level' => 'E_USER_WARNING', 'message' => $e->getMessage(), 'file' => $e->getFile(), 'line' => $e->getLine(), 'backtrace' => sprintf("BACKTRACE:\n [%s]", join("<br/>\n", $backtrace)))));
                     }
                 } else {
                     $geoCod = $data;
                 }
                 try {
                     if (!is_object($geoCod)) {
                         throw new Exception("Map object nave not been Created");
                     }
                     if ($geoCod->status != 'OK') {
                         throw new Exception("Status is not OK");
                     }
                     $location = $geoCod->results[0]->geometry->location;
                     $current_coordinates = array($location->lat, $location->lng);
                     if (in_array($current_coordinates, self::$coordinates)) {
                         self::$index += 0.0001;
                     }
                     $listing_structure['latitude'] = $location->lat + self::$index;
                     $listing_structure['longitude'] = $location->lng + self::$index;
                     self::$coordinates = array_merge(self::$coordinates, array($current_coordinates));
                 } catch (Exception $e) {
                     $backtrace = SJB_Logger::getBackTrace();
                     SJB_Error::writeToLog(array(array('level' => 'E_USER_WARNING', 'message' => $e->getMessage(), 'file' => $e->getFile(), 'line' => $e->getLine(), 'backtrace' => sprintf("BACKTRACE:\n [%s]", join("<br/>\n", $backtrace)))));
                 }
//.........这里部分代码省略.........
开发者ID:Maxlander,项目名称:shixi,代码行数:101,代码来源:ListingIterator.php

示例2: setListingsUsingUrl

 /**
  * @param string $url
  */
 private static function setListingsUsingUrl($url)
 {
     $listings = array();
     $xmlString = SJB_HelperFunctions::getUrlContentByCurl($url);
     if ($xmlString !== false) {
         $doc = new DOMDocument();
         try {
             $doc->loadXML($xmlString, LIBXML_NOERROR);
             $results = $doc->getElementsByTagName('item');
             if ($results instanceof DOMNodeList) {
                 foreach ($doc->getElementsByTagName('item') as $result) {
                     $result = simplexml_import_dom($result);
                     $listings[] = array('Title' => htmlspecialchars_decode((string) $result->title), 'CompanyName' => (string) isset($result->company) ? $result->company : '', 'JobDescription' => (string) $result->description, 'Location' => array('Country' => isset($result->county) ? (string) $result->county : '', 'State_Code' => isset($result->state) ? (string) $result->state : '', 'City' => (string) $result->city), 'activation_date' => (string) $result->postdate, 'url' => $result->link, 'target' => 'target="_blank" ', 'api' => 'juju', 'code' => '<span id="juju_at"><a href="http://www.juju.com/">jobs</a> by <a href="http://www.juju.com/" title="Job Search"><img src="http://www.job-search-engine.com/assets/images/juju_logo.png" style="width: 54px; height: auto; border: 0; vertical-align: middle;"></a></span>');
                 }
             }
         } catch (ErrorException $e) {
             SJB_Logger::error($e->getMessage());
         }
     }
     self::$jujuListings = $listings;
 }
开发者ID:Maxlander,项目名称:shixi,代码行数:24,代码来源:juju_plugin.php

示例3: getListingsFromSimplyHired

 public static function getListingsFromSimplyHired($params)
 {
     $listingTypeID = SJB_ListingTypeManager::getListingTypeIDBySID($params->listing_type_sid);
     if ($listingTypeID == 'Job' && $GLOBALS['uri'] == '/search-results-jobs/' || $GLOBALS['uri'] == '/ajax/') {
         $publisherID = SJB_Settings::getSettingByName('simplyHiredPublisherID');
         $limit = SJB_Settings::getSettingByName('countSimplyHiredListings');
         $ip = $_SERVER['REMOTE_ADDR'];
         $userAgent = urlencode(SJB_Request::getUserAgent());
         $start = $limit * ($params->listing_search_structure['current_page'] - 1) + 1;
         $stateIndexes = array('AL' => 'Alabama', 'AK' => 'Alaska', 'AZ' => 'Arizona', 'AR' => 'Arkansas', 'CA' => 'California', 'CO' => 'Colorado', 'CT' => 'Connecticut', 'DE' => 'Delaware', 'FL' => 'Florida', 'GA' => 'Georgia', 'HI' => 'Hawaii', 'ID' => 'Idaho', 'IL' => 'Illinois', 'IN' => 'Indiana', 'IA' => 'Iowa', 'KS' => 'Kansas', 'KY' => 'Kentucky', 'LA' => 'Louisiana', 'ME' => 'Maine', 'MD' => 'Maryland', 'MA' => 'Massachusetts', 'MI' => 'Michigan', 'MN' => 'Minnesota', 'MS' => 'Mississippi', 'MO' => 'Missouri', 'MT' => 'Montana', 'NE' => 'Nebraska', 'NV' => 'Nevada', 'NH' => 'New Hampshire', 'NJ' => 'New Jersey', 'NM' => 'New Mexico', 'NY' => 'New York', 'NC' => 'North Carolina', 'ND' => 'North Dakota', 'OH' => 'Ohio', 'OK' => 'Oklahoma', 'OR' => 'Oregon', 'PA' => 'Pennsylvania', 'RI' => 'Rhode Island', 'SC' => 'South Carolina', 'SD' => 'South Dakota', 'TN' => 'Tennessee', 'TX' => 'Texas', 'UT' => 'Utah', 'VT' => 'Vermont', 'VA' => 'Virginia', 'WA' => 'Washington', 'WV' => 'West Virginia', 'WI' => 'Wisconsin', 'WY' => 'Wyoming', 'DC' => 'District of Columbia', 'AS' => 'American Samoa', 'GU' => 'Guam', 'MP' => 'Northern Mariana Islands', 'PR' => 'Puerto Rico', 'UM' => "United's Minor Outlying Islands", 'VI' => 'Virgin Islands');
         $countryCodes = array('United States' => 'us', 'Australia' => 'au', 'Austria' => 'at', 'Belgium' => 'be', 'Brazil' => 'br', 'Canada' => 'ca', 'France' => 'fr', 'Germany' => 'de', 'India' => 'in', 'Ireland' => 'ie', 'Italy' => 'it', 'Mexico' => 'mx', 'Netherlands' => 'nl', 'Spain' => 'es', 'Switzerland' => 'ch', 'United Kingdom' => 'gb');
         // SET PARAMS FOR REQUEST
         $keywords = '';
         $criteria = $params->criteria_saver->criteria;
         $fieldSID = SJB_ListingFieldManager::getListingFieldSIDByID('JobCategory');
         $fieldInfo = SJB_ListingFieldDBManager::getListValuesBySID($fieldSID);
         $fieldList = array();
         foreach ($fieldInfo as $val) {
             $fieldList[$val['id']] = $val['caption'];
         }
         $categoryCriteria = isset($criteria['JobCategory']['multi_like']) ? $criteria['JobCategory']['multi_like'] : '';
         if (!empty($categoryCriteria)) {
             foreach ($categoryCriteria as $category) {
                 if (!empty($fieldList[$category])) {
                     $keywords .= empty($keywords) ? $fieldList[$category] : ' OR ' . $fieldList[$category];
                 }
             }
             if (!empty($keywords)) {
                 $keywords = "({$keywords})";
             }
         }
         foreach ($criteria as $field) {
             if (is_array($field)) {
                 foreach ($field as $fieldType => $values) {
                     if ($fieldType == 'multi_like_and') {
                         foreach ($values as $val) {
                             $keywords .= empty($keywords) ? $val : ' ' . $val;
                         }
                     }
                 }
             }
         }
         if (isset($criteria['keywords']) && !empty($criteria['keywords'])) {
             foreach ($criteria['keywords'] as $key => $item) {
                 if (in_array($key, array('exact_phrase', 'any_words', 'all_words', 'like'))) {
                     $keywords .= $item;
                 }
             }
         }
         $systemKeywords = trim(SJB_Settings::getSettingByName('simplyHiredKeyword'));
         $keywords = $systemKeywords ? '(' . $systemKeywords . ')' . ($keywords ? ' OR (' . $keywords . ')' : '') : $keywords;
         $keywords = preg_replace('/\\s+/', ' ', $keywords);
         $keywords = str_replace(',', '', $keywords);
         $keywords = urlencode(trim($keywords));
         $location = self::getLocation($criteria, 'simplyHiredLocation');
         $radius = SJB_Settings::getSettingByName('simplyHiredMiles');
         if (isset($criteria['Location_ZipCode']['geo']['radius']) && !empty($criteria['Location_ZipCode']['geo']['radius'])) {
             $radius = $criteria['Location_ZipCode']['geo']['radius'];
             if ($radius == 'any') {
                 $radius = '';
             }
         }
         $sortBy = SJB_Settings::getSettingByName('simplyHiredSortBy');
         $siteUrl = SJB_Settings::getSettingByName('simplyHiredSiteUrl');
         $jobAMaticDomain = SJB_Settings::getSettingByName('jobAMaticDomain', false);
         if (!empty($jobAMaticDomain) && $siteUrl == 'simplyhired.com') {
             $jobAMaticDomain = str_replace('http://', '', $jobAMaticDomain);
             $jobAMaticDomain = str_replace('/', '', $jobAMaticDomain);
             $jobAMaticDomain = "&jbd={$jobAMaticDomain}";
         } else {
             $jobAMaticDomain = '';
         }
         if ($siteUrl == 'simplyhired.com') {
             $ssty = 2;
         } else {
             $ssty = 3;
         }
         $url = "http://api.{$siteUrl}/a/jobs-api/xml-v2/q-{$keywords}/l-{$location}/mi-{$radius}/ws-{$limit}/pn-{$params->listing_search_structure['current_page']}/sb-{$sortBy}?pshid={$publisherID}&ssty={$ssty}&cflg=r{$jobAMaticDomain}&clip={$ip}";
         $sxml = new simplexml();
         $xmlString = SJB_HelperFunctions::getUrlContentByCurl($url);
         $simplyhiredListings = array();
         if ($xmlString === false) {
             //				throw new Exception("simplyHiredPlugin: Failed to read XML from url - {$url}");
             SJB_Logger::error("simplyHiredPlugin: Failed to read XML from url - {$url}");
         } else {
             //$tree = $sxml->xml_load_file($url, 'array');
             $tree = $sxml->xml_load_file($xmlString, 'array');
             $totalResults = 0;
             if ($tree !== false) {
                 $results = isset($tree['rs']) ? $tree['rs'] : array();
                 $outputCountry = array_flip($countryCodes);
                 foreach ($results as $node) {
                     if ($tree['rq']['rpd'] == 1) {
                         $node = array($node);
                     }
                     foreach ($node as $key => $result) {
                         $state = (string) $result['loc']['@attributes']['st'];
                         $country = (string) $result['loc']['@attributes']['country'];
                         $simplyhiredListings[$key] = array('Title' => (string) $result['jt'], 'CompanyName' => (string) isset($result['cn']['@content']) ? $result['cn']['@content'] : '', 'JobDescription' => (string) $result['e'], 'Location' => array('Country' => empty($country) ? '' : (isset($outputCountry[strtolower($country)]) ? $outputCountry[strtolower($country)] : ''), 'State' => empty($location[1]) ? '' : (isset($stateIndexes[strtoupper($state)]) ? $stateIndexes[strtoupper($state)] : ''), 'State_Code' => empty($state) ? '' : strtoupper($state), 'City' => (string) $result['loc']['@attributes']['cty']), 'activation_date' => (string) $result['dp'], 'url' => (string) $result['src']['@attributes']['url'], 'api' => 'simplyHired', 'onmousedown' => ' onMouseDown="xml_sclk(this);" ', 'target' => ' target="_blank"', 'onclick' => 'onclick="addStatisticsForSimplyHired();" ', 'code' => '<span style="font-size:10px; position:relative; top:-5px; font-family:Arial,sans-serif;color: #333;"><a style="color: #333; text-decoration:none" href="' . SJB_Request::getProtocol() . '://www.simplyhired.com/">Jobs</a> by</span> <a STYLE="text-decoration:none" href="' . SJB_Request::getProtocol() . '://www.simplyhired.com/"><img src="' . SJB_Request::getProtocol() . '://www.jobamatic.com/c/jbb/images/simplyhired.png" alt="Simply Hired"></a>');
                     }
//.........这里部分代码省略.........
开发者ID:Maxlander,项目名称:shixi,代码行数:101,代码来源:simply_hired_plugin.php

示例4: execute


//.........这里部分代码省略.........
                 if (!empty($fileUniqueId)) {
                     $upload_manager = new SJB_UploadFileManager();
                     // file structure for videoplayer
                     $fileInfo = array('file_url' => $upload_manager->getUploadedFileLink($fileUniqueId), 'file_name' => $upload_manager->getUploadedFileName($fileUniqueId), 'saved_file_name' => $upload_manager->getUploadedSavedFileName($fileUniqueId), 'file_id' => $fileUniqueId);
                     $listing_structure[$fieldId] = $fileInfo;
                 }
             }
         }
         // SJB-1197
         // GOOGLE MAP SEARCH RESULTS CUSTOMIZATION
         $zipCode = '';
         if (!empty($listing_structure['Location']['ZipCode'])) {
             $zipCode = $listing_structure['Location']['ZipCode'];
         }
         // get 'latitude' and 'longitude' from zipCode field, if it not set
         $latitude = isset($listing_structure['latitude']) ? $listing_structure['latitude'] : '';
         $longitude = isset($listing_structure['longitude']) ? $listing_structure['longitude'] : '';
         if (!empty($zipCode) && empty($latitude) && empty($longitude)) {
             $result = SJB_DB::query("SELECT * FROM `locations` WHERE `name` = ?s LIMIT 1", $zipCode);
             if ($result) {
                 $listing_structure['latitude'] = $result[0]['latitude'];
                 $listing_structure['longitude'] = $result[0]['longitude'];
             }
         } elseif (!empty($listing_structure['Location']['City']) && !empty($listing_structure['Location']['State']) && !empty($listing_structure['Location']['Country'])) {
             $address = $listing_structure['Location']['City'] . ', ' . $listing_structure['Location']['State'] . ', ' . $listing_structure['Location']['Country'];
             $address = urlencode($address);
             $cache = SJB_Cache::getInstance();
             $parameters = array('City' => $listing_structure['Location']['City'], 'State' => $listing_structure['Location']['State'], 'Country' => $listing_structure['Location']['Country']);
             $hash = md5('google_map' . serialize($parameters));
             $data = $cache->load($hash);
             $geoCod = '';
             if (!$data) {
                 try {
                     $geoCod = SJB_HelperFunctions::getUrlContentByCurl("http://maps.googleapis.com/maps/api/geocode/json?address={$address}&sensor=false");
                     $geoCod = json_decode($geoCod);
                     if ($geoCod->status == 'OK') {
                         $cache->save($geoCod, $hash);
                     }
                 } catch (Exception $e) {
                     $backtrace = SJB_Logger::getBackTrace();
                     SJB_Error::writeToLog(array(array('level' => 'E_USER_WARNING', 'message' => $e->getMessage(), 'file' => $e->getFile(), 'line' => $e->getLine(), 'backtrace' => sprintf("BACKTRACE:\n [%s]", join("<br/>\n", $backtrace)))));
                 }
             } else {
                 $geoCod = $data;
             }
             try {
                 if (!is_object($geoCod)) {
                     throw new Exception("Map object nave not been Created");
                 }
                 if ($geoCod->status !== 'OK') {
                     throw new Exception("Status is not OK");
                 }
                 $location = $geoCod->results[0]->geometry->location;
                 $listing_structure['latitude'] = $location->lat;
                 $listing_structure['longitude'] = $location->lng;
             } catch (Exception $e) {
                 $backtrace = SJB_Logger::getBackTrace();
                 SJB_Error::writeToLog(array(array('level' => 'E_USER_WARNING', 'message' => $e->getMessage(), 'file' => $e->getFile(), 'line' => $e->getLine(), 'backtrace' => sprintf("BACKTRACE:\n [%s]", join("<br/>\n", $backtrace)))));
             }
         }
         if (SJB_Request::getVar('view')) {
             $tp->assign('listings', array($listing_structure));
         }
         $tp->filterThenAssign("listing", $listing_structure);
         $tp->assign("prev_next_ids", $prevNextIds);
         $tp->assign("searchId", $searchId);
开发者ID:Maxlander,项目名称:shixi,代码行数:67,代码来源:display_listing.php


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