Created
July 16, 2011 04:14
-
-
Save qiukun/1085995 to your computer and use it in GitHub Desktop.
check the price and send sms via fetion
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$mysql = new SaeMysql(); | |
$sql = "SELECT `uid` FROM `users`"; | |
$users = $mysql->getData($sql); | |
foreach($users as $userline) { | |
$uid = $userline['uid']; | |
$sql = "SELECT * FROM `phones` WHERE `uid` = $uid"; | |
$phones = $mysql->getData($sql); | |
$sql = "SELECT * FROM `stocks` WHERE `uid` = $uid"; | |
$stocks = $mysql->getData($sql); | |
foreach ($stocks as $stockline) { | |
$code = $stockline['code']; | |
$price = $stockline['price']; | |
//get data | |
$url = "http://api.liqwei.com/stock/?code=$code"; | |
$data = file_get_contents($url); | |
$elements = explode(",", $data); | |
$cprice = $elements[1]; // current price | |
//send msg | |
foreach ($phones as $phoneline) { | |
$phone = $phoneline['phone']; | |
$pwd = $phoneline['pwd']; | |
if ($price >= $cprice - 0.05 || $price <= $cprice + 0.05) { | |
$url = "http://sms.bber.info/api.php?phone=$phone&pwd=$pwd&to=$phone&msg=$code,$cprice"; | |
fopen("$url", 'r'); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment