dever 5 rokov pred
rodič
commit
465a5d3d62
1 zmenil súbory, kde vykonal 41 pridanie a 0 odobranie
  1. 41 0
      app/collection/src/Api.php

+ 41 - 0
app/collection/src/Api.php

@@ -88,4 +88,45 @@ class Api
 
         return $data;
     }
+
+    public function test()
+    {
+        $limit = 0;
+        $num = 10000;
+        $state = true;
+        while($state) {
+            $data = $this->tdata($limit, $num);
+            if ($data) {
+                $state = true;
+                foreach ($data as $k => $v) {
+                    if ($v['mobile'] && strstr($v['mobile'], '1')) {
+                        $this->tupdate($v['id'], $v['mobile']);
+                    }
+                }
+            } else {
+                $state = false;
+            }
+        }
+
+        return 'ok';
+    }
+
+    public function tupdate($id, $mobile)
+    {
+        $url = 'https://sp0.baidu.com/8aQDcjqpAAV3otqbppnN2DJv/api.php?query={mobile}&resource_id=6004&ie=utf8&oe=utf8&format=json';
+        $url = str_replace('{mobile}', $mobile, $url);
+        $result = Dever::curl($url);
+        $result = json_decode($result, true);
+        if (isset($result['data'][0]['city'])) {
+            $sql = 'update huala_member set citys = "'.$result['data'][0]['city'].'" where id = ' . $id;
+            Dever::db('collection/info')->query($sql);
+        }
+    }
+
+    public function tdata($limit, $num)
+    {
+        $sql = 'select * from huala_member where citys is null order by id asc limit ' . $limit . ',' . $num;
+        $data = Dever::db('collection/info')->fetchAll($sql);
+        return $data;
+    }
 }