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.
 
 
 
 
 
 

253 lines
6.8 KiB

  1. <?php
  2. header('Content-Type:text/html; charset=utf-8');
  3. date_default_timezone_set('PRC');
  4. include('SVN/ZZWX/ZZDZ/config/Mysql.php');
  5. //$time = "2016-09-17 10:17:31";
  6. //echo substr($time,0,10),substr($time,11,5);;
  7. $pdo =conn();
  8. $sql = "SELECT * FROM `wechat_user` where id >2000";
  9. $result = $pdo->query($sql);
  10. $rowset = $result->fetchAll(PDO::FETCH_ASSOC);
  11. foreach ($rowset as $key => $value) {
  12. $result = httpRequest2('https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=wxbe6da4af3e529e0c&secret=7c1b14020e87e9e213696e870da0e549');
  13. $token = (array)json_decode($result);
  14. $token =$token['access_token'];
  15. $result = httpRequest2('https://api.weixin.qq.com/cgi-bin/user/info?access_token='.$token.'&openid='.$value['OPENID'].'&lang=zh_CN');
  16. $res = (array)json_decode($result);
  17. if(isset($res['subscribe']) && $res['subscribe']==1){
  18. $sql = "update wechat_user set CITY ='".$res['city']."', is_register =1,NICKNAME ='".$res['nickname']."',SEX =".$res['sex'].",COUNTRY ='".$res['country']."',PROVINCE ='".$res['province']."' where id =".$value['ID'];
  19. $result = $pdo->query($sql);
  20. echo $sql;
  21. }
  22. // var_dump($res);
  23. }
  24. die;
  25. // die;
  26. // function gen() {
  27. // $ret = (yield 'yield1');
  28. // var_dump($ret);
  29. // $ret = (yield 'yield2');
  30. // var_dump($ret);
  31. // }
  32. // $gen = gen();
  33. // var_dump($gen->current()); // string(6) "yield1"
  34. // var_dump($gen->send('ret1')); // string(4) "ret1" (the first var_dump in gen)
  35. // // string(6) "yield2" (the var_dump of the ->send() return value)
  36. // var_dump($gen->send('ret2')); // string(4) "ret2" (again from within gen)
  37. // // NULL (the return value of ->send())
  38. // die;
  39. // $mycustomer ='{,但复苏的,1,18663582623,150,,,0,,}';
  40. // $end_area_id = 6;
  41. // $end_time ='12:06';
  42. // $myprod ='{m449867p1|r597375}';
  43. // $start_area_id = 2;
  44. // $start_time ='08:28';
  45. $result = post2('wx.zhizhuchuxing.com/ZZDZ2/application/custom_made/control.php', array(
  46. 'type' => 'order_refund22',
  47. 'order_id'=>477982
  48. ));
  49. var_dump($result);
  50. die;
  51. function baiduShortTime($origins, $destinations)
  52. {
  53. $data = array('origins' => $origins, 'destinations' => $destinations, 'output' => 'json', 'tactics' => 11, 'ak' => commonUtils::$AK);
  54. //var_dump($data);exit();
  55. $res = commonUtils::send_get(commonUtils::$URL, $data);
  56. $shortTimeList = json_decode($res, true);
  57. if (isset($shortTimeList['status']) && $shortTimeList['status'] == 0) {
  58. foreach ($shortTimeList['result'] as $res) {
  59. if (count($shortTimeList['result']) > 1) {
  60. $time[] = ceil(($res['duration']['value']) / 60);
  61. } else {
  62. $time = ceil(($res['duration']['value']) / 60);
  63. }
  64. }
  65. return $time;
  66. } else {
  67. return false;
  68. }
  69. }
  70. echo baiduShortTime('31.9779550000,118.8036120000','32.0557350000,118.9010530000');
  71. die;
  72. $result = post2('http://sfx.zhizhuchuxing.com/zz-fx/Model/distribut/OrderDetail.php',array('order_id'=>'179314'));
  73. var_dump($result);
  74. die;
  75. $base_url = "http://api.hstsp.cn:8077/data/";
  76. $account_id = "hdgps";
  77. $account_pwd = md5("123456");
  78. $login_url = $base_url."login/tokenDuration.do?account={$account_id}&passwd={$account_pwd}";
  79. $result = httpRequest( $login_url );
  80. $result_array = json_decode($result,true);
  81. $token_str = $result_array["tokenStr"];
  82. $check_car_no = urlencode("沪B61353");
  83. $get_car_id_url = $base_url."LogisticalCar/queryCarId.do?tokenStr={$token_str}&plateCodes={$check_car_no}";
  84. $result =httpRequest( $get_car_id_url );
  85. $result_array = json_decode($result,true);
  86. $a = printf("%.0f",$result_array["Data"][0]["id"]);
  87. $car_id = implode(',', $result_array["Data"][0]);
  88. var_dump($result_array);
  89. die;
  90. $get_car_info_url = $base_url."VehicleMonitor/queryMultiVehicleLocation.do?tokenStr={$token_str}&vehicleIds=". $car_id."&mapType=1";
  91. $result = httpRequest( $get_car_info_url );
  92. $result_array = json_decode($result,true);
  93. echo $get_car_info_url;
  94. var_dump($result);
  95. function httpRequest2($url, $data = array(1)){//file_get_content
  96. $postdata = http_build_query(
  97. $data
  98. );
  99. $opts = array('http' =>
  100. array(
  101. 'method' => 'get',
  102. 'header' => 'Content-type: application/x-www-form-urlencoded',
  103. 'content' => $postdata
  104. )
  105. );
  106. $context = stream_context_create($opts);
  107. $result = file_get_contents($url, false, $context);
  108. return $result;
  109. }
  110. die;
  111. $myprod='{m449862p1|r577810}';
  112. $mycustomer='{,z,1,15139094100,150,,,0,,}';
  113. $ticket_id = substr($myprod, strpos($myprod, 'm') + 1, strpos($myprod, 'p') - 2);
  114. if($ticket_id== 449862 ||$ticket_id == 449867 ){
  115. if($ticket_id== 449862){//463597 464032 464413
  116. $result = post2('http://wx.zhizhuchuxing.com/ZZDZ/application/custom_made/control.php',array(
  117. 'type' =>'order_submitforout',
  118. 'prod_list'=>$myprod,
  119. 'customer_info'=>$mycustomer,
  120. 'start_name'=>'南京五塘广场',
  121. 'end_name'=>'南通政务中心',
  122. 'startx_y'=>'32.116818,118.784015',
  123. 'endx_y'=>'31.991326,120.892807',
  124. 'line_id'=>'449860',
  125. 'start_time'=>'07:37',
  126. 'end_time'=>'10:30'
  127. ));
  128. echo $result;die;
  129. }
  130. if($ticket_id== 449867){//464259 464331
  131. $result = post2('http://wx.zhizhuchuxing.com/ZZDZ/application/custom_made/control.php',array(
  132. 'type' =>'order_submitforout',
  133. 'prod_list'=>$myprod,
  134. 'customer_info'=>$mycustomer,
  135. 'start_name'=>'南通政务中心',
  136. 'end_name'=>'南京五塘广场',
  137. 'endx_y'=>'32.116818,118.784015',
  138. 'startx_y'=>'31.991326,120.892807',
  139. 'line_id'=>'449865',
  140. 'start_time'=>'07:37',
  141. 'end_time'=>'10:30'
  142. ));
  143. echo $result;die;
  144. }
  145. }
  146. function post2($url, $post_data = '', $timeout = 5){//curl
  147. $ch = curl_init();
  148. curl_setopt ($ch, CURLOPT_URL, $url);
  149. curl_setopt ($ch, CURLOPT_POST, 1);
  150. if($post_data != ''){
  151. curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
  152. }
  153. curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
  154. curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
  155. curl_setopt($ch, CURLOPT_HEADER, false);
  156. $file_contents = curl_exec($ch);
  157. curl_close($ch);
  158. return $file_contents;
  159. }