Skip to content

Instantly share code, notes, and snippets.

@qiukun
Created July 16, 2011 04:14
Show Gist options
  • Save qiukun/1085995 to your computer and use it in GitHub Desktop.
Save qiukun/1085995 to your computer and use it in GitHub Desktop.
check the price and send sms via fetion
<?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