You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

58 lines
2.3 KiB

  1. <?php
  2. require_once '../st-xm/Common/Mysql.php';
  3. header("Access-Control-Allow-Origin:*");
  4. /**
  5. * Created by PhpStorm.
  6. * User: Administrator
  7. * Date: 2016/8/20
  8. * Time: 9:11
  9. */
  10. define("API_ACCOUNT", "15618818219");
  11. define("API_PASSWORD", "123456");
  12. $test_time = date("Y-m-d H:i:s", 1924912800);echo $test_time."<hr />";
  13. //获取账户信息
  14. $unix_time = time();
  15. $signature = md5(md5(API_PASSWORD).$unix_time);
  16. $url='http://api.gpsoo.net/1/auth/access_token?account='.API_ACCOUNT.'&time='.$unix_time.'&signature='.$signature;
  17. $html = file_get_contents($url);
  18. $return_array = json_decode($html,true);
  19. $access_token = $return_array["access_token"];
  20. //获取经纬度等
  21. $common_url = 'access_token='.$access_token.'&account='.API_ACCOUNT.'&time='.$unix_time;
  22. $url1 = 'http://api.gpsoo.net/1/account/monitor?'.$common_url.'&map_type=BAIDU&target='.API_ACCOUNT;
  23. $html1 = file_get_contents($url1);
  24. $return_array1 = json_decode($html1,true);
  25. $lng = $return_array1["data"][0]["lng"];
  26. $lat = $return_array1["data"][0]["lat"];
  27. //获取设备号
  28. $url2='http://api.gpsoo.net/1/account/devinfo?target='.API_ACCOUNT.'&'.$common_url;
  29. //http://api.gpsoo.net/1/account/devinfo?target=test&account=test&access_token=200071015892101425870161325c151729a416478ac71fe7588b70609800010010014010 &time=1386655342
  30. $html2 = file_get_contents($url2);
  31. $return_array2 = json_decode($html2,true);
  32. print_r($return_array2);
  33. $pdo = conn();
  34. //获取信息
  35. foreach( $return_array2["data"] as $data_info ) {
  36. $imei = $data_info["imei"];
  37. $name = $data_info["name"];
  38. $number = $data_info["number"];
  39. $phone = $data_info["phone"];
  40. $tel = $data_info["tel"];
  41. $group_id = $data_info["group_id"];
  42. $group_name = $data_info["group_name"];
  43. $dev_type = $data_info["dev_type"];
  44. $owner = $data_info["owner"];
  45. $in_time = $data_info["in_time"];
  46. $out_time = $data_info["out_time"];
  47. $sudu = $data_info["sudu"];
  48. $efence_support = $data_info["efence_support"];
  49. $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') " .
  50. " ON DUPLICATE KEY UPDATE imei='{$imei}' ";//比对键值,重复插入时为更新
  51. $result = $pdo->exec($sql1);
  52. $result->closeCursor();
  53. }