|
@@ -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;
|
|
|
+ }
|
|
|
}
|