|
- <?php
- require_once '../st-xm/Common/Mysql.php';
- header("Access-Control-Allow-Origin:*");
- /**
- * Created by PhpStorm.
- * User: Administrator
- * Date: 2016/8/20
- * Time: 9:11
- */
- define("API_ACCOUNT", "15618818219");
- define("API_PASSWORD", "123456");
-
- $test_time = date("Y-m-d H:i:s", 1924912800);echo $test_time."<hr />";
-
- //获取账户信息
- $unix_time = time();
- $signature = md5(md5(API_PASSWORD).$unix_time);
- $url='http://api.gpsoo.net/1/auth/access_token?account='.API_ACCOUNT.'&time='.$unix_time.'&signature='.$signature;
- $html = file_get_contents($url);
- $return_array = json_decode($html,true);
- $access_token = $return_array["access_token"];
- //获取经纬度等
- $common_url = 'access_token='.$access_token.'&account='.API_ACCOUNT.'&time='.$unix_time;
-
- $url1 = 'http://api.gpsoo.net/1/account/monitor?'.$common_url.'&map_type=BAIDU&target='.API_ACCOUNT;
- $html1 = file_get_contents($url1);
- $return_array1 = json_decode($html1,true);
- $lng = $return_array1["data"][0]["lng"];
- $lat = $return_array1["data"][0]["lat"];
-
- //获取设备号
- $url2='http://api.gpsoo.net/1/account/devinfo?target='.API_ACCOUNT.'&'.$common_url;
- //http://api.gpsoo.net/1/account/devinfo?target=test&account=test&access_token=200071015892101425870161325c151729a416478ac71fe7588b70609800010010014010 &time=1386655342
- $html2 = file_get_contents($url2);
- $return_array2 = json_decode($html2,true);
- print_r($return_array2);
- $pdo = conn();
- //获取信息
- foreach( $return_array2["data"] as $data_info ) {
- $imei = $data_info["imei"];
- $name = $data_info["name"];
- $number = $data_info["number"];
- $phone = $data_info["phone"];
- $tel = $data_info["tel"];
- $group_id = $data_info["group_id"];
- $group_name = $data_info["group_name"];
- $dev_type = $data_info["dev_type"];
- $owner = $data_info["owner"];
- $in_time = $data_info["in_time"];
- $out_time = $data_info["out_time"];
- $sudu = $data_info["sudu"];
- $efence_support = $data_info["efence_support"];
-
- $sql1 = "INSERT INTO device(imei,name,number,phone,tel,group_id,group_name,dev_type,owner,in_time,out_time,sudu,efence_support)VALUES('$imei','$name','$number','$phone','$tel','$group_id','$group_name','$dev_type','$owner','$in_time','$out_time','$sudu','$efence_support') " .
- " ON DUPLICATE KEY UPDATE imei='{$imei}' ";//比对键值,重复插入时为更新
- $result = $pdo->exec($sql1);
- $result->closeCursor();
- }
|