Sina Constellation API free Open horoscope 12 zodiac work Love financial health talks feng Shui learning speed Dating
$astroDir = './'; $astroArray = Array (' aries ' = = Array (' Aries ', ' 03/21-04/19 '), ' taurus ' = = Array (' Taurus ') , ' 04/20-05/20 '), ' gemini ' = = Array (' Gemini ', ' 05/21-06/21 '), ' cancer ' = = Array (' Cancer ', ' 06/22-07/22 '), ' Leo ' = = Array (' Leo ', ' 07/23-08/22 '), ' virgo ' = = Array (' virgo ', ' 08/23-09/22 '), ' libra ' = = Array (' Libra ', ' 09/23-10/23 '), ' scorpio ' = = Array (' Scorpio ', ' 10/24-11/22 '), ' sagittarius ' = = Array (' Sagittarius ', ' 11/23 -12/21 '), ' capricorn ' = = Array (' capricorn ', ' 12/22-01/19 '), ' aquarius ' = = Array (' Aquarius ', ' 01/20-02/18 '), ' pisces ' = = Array (' pisces ', ' 02/19-03/20 ')); function Generateastro () {global $astroDir, $astroArray; $fileLog = $astroDir. '. Log '; $log = Is_file ($fileLog)? Json_decode (file_get_contents ($fileLog)): false; if (!isset ($log->latesttime) | | $log->latesttime < date (' y-m-d ')} {foreach ($astroArray as $astro) { Preg_match ('/(.*?)(.*?) <\/em><\/span>.*? Date of validity: (. *?) Integrated Horoscope (. *?) Love Horoscope (. *?) Work status (. *?) Financial investment (. *?) Health index (. *?) Negotiation index (. *?) Lucky Color (. *?) Lucky number (. *?) Speed dating (. *?) (.*?) <\/div>/isu ', curl (' http://vip.astro.sina.com.cn/astro/view/'. $astro [0]. ' /day/', $astro [0]), $matches); File_put_contents ($astroDir. $astro [0]. Dat ', Json_encode (Array ($matches [1], $matches [2], Html2txt ($matches [3]), Substr_count ($matches [4], ' Html2txt ($ MATCHES[3])); Unset ($matches); }} function Getastrobydate ($date) {global $astroArray; foreach ($astroArray as $k = + $v) {$value = explode ('-', $v [1]); if (date ($value [0]) <= date ($date) && date ($date) <= date ($value [1]) {return $k; }} return ' Capricorn '; function Html2txt ($document) {$search = array (' @ @si ',//Strip out JavaScript ' @<[\/\!] *? [^<>]*?> @si ',//Strip out HTML tags ' @
]*?>.*?@siU ',//Strip style tags properly ' @
@ ',//Strip multi-line comments including CDATA ' @\s+| @' ); $text = Preg_replace ($search, ", $document); return $text;} Function Curl ($url, $type) {$ch = Curl_init (); curl_setopt ($ch, Curlopt_url, $url); curl_setopt ($ch, Curlopt_returntransfer, 1); curl_setopt ($ch, Curlopt_referer, ' Http://astro.sina.com.cn/fate/astro_ '. $type. Html?prourl=0 '); curl_setopt ($ch, curlopt_useragent, ' mozilla/'. Mt_rand (2, 9). 0 (Windows NT 6.1; WOW64; RV: '. Mt_rand (10, 30). '. 0) gecko/'. Mt_rand (2000, 2014). ' 0101 firefox/'. Mt_rand (10, 30). 0 '); curl_setopt ($ch, Curlopt_header, 0); $data = curl_exec ($ch); Curl_close ($ch); return $data;} function Isbirthdate ($date) {if (empty ($date) | | $date = = ' 0000-00-00 ') return false; if (Preg_match ('/^ ')-((?: 0? [1-9]) | (?: 1[0-2])) -((?: 0? [1-9]) | (?: [1-2][0-9]) | (?: 3[01])) ([0-9]{2}:[0-9]{2}:[0-9]{2})? $/', $date, $birth _date) {return ($birth _date[1]. ' -'. $birth _date[2]. ' -'. $birth _date[3] <= date (' y-m-d ')); } return false;} Http://my.oschina.net/cart/var_dump (isbirthdate (' 2012-02-05 '));//Verify that birthdays are valid Var_dump (getastrobydate (' 02-05 ')) ;//Obtain Constellation name Generateastro () by date;//collect only 1 constellation data per day Var_dump (Json_decode (file_get_contents ($astroDir. Log '));//Get the current constellation content time//http://my.oschina.net/cart/