查看: 246|回复: 0

[源码分享] 小米运动步数API接口 PHP源码分享

[复制链接]
发表于 2022-7-27 19:35 | 显示全部楼层 |阅读模式
qa258 2022-7-27 19:35 246 0 显示全部楼层
我不信还说我引流 你king 你擦

  1. <?php
  2. error_reporting(0);//抑制所有错误
  3. header('Access-Control-Allow-Origin: *');
  4. header('Content-type:application/json; charset=utf-8');
  5. echo shuabu($_GET['user'],$_GET['pass'],$_GET['count']);

  6. function shuabu($user,$pass,$count){
  7.     if($user==''){$json = array("code"=>207,"msg"=>'小米运动账号不能为空',);return json_encode($json,JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);}
  8.     if($pass==''){$json = array("code"=>202,"msg"=>'小米运动密码不能为空',);return json_encode($json,JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);}
  9.     if($count==''){$json = array("code"=>205,"msg"=>'小米运动步数不能为空',);return json_encode($json,JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);}
  10.     if(preg_match("/^1[3456789]\d{9}$/", $user) == 0) {$json = array("code"=>203,"msg"=>'手机号格式错误!',);return json_encode($json,JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);}
  11.     if(intval($count)<= 0){$json = array("code"=>206,"msg"=>'步数格式错误!',);return json_encode($json,JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);}
  12.     if(intval($count)>99999){$json = array("code"=>204,"msg"=>'步数最大限制为99999',);return json_encode($json,JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);}
  13.     $access = login($user,$pass);
  14.     if($access == ''){
  15.         $json = array(
  16.             "code"=>201,
  17.             "msg"=>'小米运动账号或者密码错误',
  18.         );
  19.         return json_encode($json,JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
  20.     }
  21.     $user_json = get_user($access);
  22.     $user_id = get_user_id($user_json);
  23.     $app_token = get_app_token($user_json);
  24.     $return = json_decode(load($user_id,$app_token,$count),true);
  25.     if($return['code']=='1'){
  26.         $json = array(
  27.             "code"=>200,
  28.             "msg"=>'提交步数成功',
  29.             "user"=>$_GET['user'],
  30.             "count"=>$_GET['count']
  31.         );
  32.     }else{
  33.         $json = array(
  34.             "code"=>208,
  35.             "msg"=>'提交步数失败,API返回结果为:'.$json['message'].'',
  36.             "user"=>$_GET['user'],
  37.             "count"=>$_GET['count']
  38.         );
  39.     }
  40.     return json_encode($json,JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
  41. }   
  42. function login($user,$pass){//登录,成功返回access,失败返回空
  43.     $data_url = 'https://api-user.huami.com/registrations/+86'.$user.'/tokens';
  44.     $post_data = array(
  45.         "client_id" => "HuaMi",
  46.         "country_code" => "CN",
  47.         "password" => $pass,
  48.         "redirect_uri" => "https%3A//s3-us-west-2.amazonaws.com/hm-registration/successsignin.html",
  49.         "state" => "REDIRECTION",
  50.         "token" => "access"
  51.     );
  52.     $return = curl_sport($data_url,$post_data,1);
  53.     if(strexists($return,'access')){
  54.         return GetBetween($return,'access=','&');
  55.     }else{
  56.         return '';
  57.     }
  58. }
  59. function get_user($access){//获取用户信息,json类型
  60.     $data_url = 'https://account.huami.com/v2/client/login';
  61.     $post_data="allow_registration=false&app_name=com.xiaomi.hm.health&app_version=4.1.0&code=".$access."&country_code=CN&device_id=device_id_type=uuid&device_model=phone&dn=api-user.huami.com%2Capi-mifit.huami.com%2Capp-analytics.huami.com&grant_type=access_token&lang=zh_CN&os_version=1.5.0&source=com.xiaomi.hm.health&third_name=huami_phone";
  62.     $return = curl_sport($data_url,$post_data,0);
  63.     return $return;     
  64. }
  65. function load($user_id,$app_token,$count){//提交步数
  66.     $data_url = "https://api-mifit-cn.huami.com/v1/data/band_data.json?&t=" . time();
  67.     $headers = [
  68.             'apptoken: ' . $app_token,
  69.             'User-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 13_4_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 MicroMessenger/7.0.12(0x17000c2d) NetType/WIFI Language/zh_CN'
  70.         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gAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAA","tz":32,"did":"DA932FFFFE8816E7","src":24}],"summary":"{"v":6,"slp":{"st":1628296479,"ed":1628296479,"dp":0,"lt":0,"wk":0,"usrSt":-1440,"usrEd":-1440,"wc":0,"is":0,"lb":0,"to":0,"dt":0,"rhr":0,"ss":0},"stp":{"ttl":' . $count . ',"dis":10627,"cal":510,"wk":41,"rn":50,"runDist":7654,"runCal":397,"stage":[{"start":327,"stop":341,"mode":1,"dis":481,"cal":13,"step":680},{"start":342,"stop":367,"mode":3,"dis":2295,"cal":95,"step":2874},{"start":368,"stop":377,"mode":4,"dis":1592,"cal":88,"step":1664},{"start":378,"stop":386,"mode":3,"dis":1072,"cal":51,"step":1245},{"start":387,"stop":393,"mode":4,"dis":1036,"cal":57,"step":1124},{"start":394,"stop":398,"mode":3,"dis":488,"cal":19,"step":607},{"start":399,"stop":414,"mode":4,"dis":2220,"cal":120,"step":2371},{"start":415,"stop":427,"mode":3,"dis":1268,"cal":59,"step":1489},{"start":428,"stop":433,"mode":1,"dis":152,"cal":4,"step":238},{"start":434,"stop":444,"mode":3,"dis":2295,"cal":95,"step":2874},{"start":445,"stop":455,"mode":4,"dis":1592,"cal":88,"step":1664},{"start":456,"stop":466,"mode":3,"dis":1072,"cal":51,"step":1245},{"start":467,"stop":477,"mode":4,"dis":1036,"cal":57,"step":1124},{"start":478,"stop":488,"mode":3,"dis":488,"cal":19,"step":607},{"start":489,"stop":499,"mode":4,"dis":2220,"cal":120,"step":2371},{"start":500,"stop":511,"mode":3,"dis":1268,"cal":59,"step":1489},{"start":512,"stop":522,"mode":1,"dis":152,"cal":4,"step":238}]},"goal":8000,"tz":"28800"}","source":24,"type":0}]';
  72.     $data = [
  73.             'data_json' => $json,
  74.             'userid' => $userid,
  75.             'device_type' => '0',
  76.             'last_sync_data_time' => '1597306380',
  77.             'last_deviceid' => 'DA932FFFFE8816E7',
  78.         ];
  79.     $return=Curl($data_url, $data, null, $headers);
  80.     $return2=json_encode(array('code'=>1,'msg'=>'提交成功'));
  81.     return $return2;
  82. }
  83. function get_user_id($user_json){//解析user_json,获取user_id
  84.     $json = json_decode($user_json,true);
  85.     return $json['token_info']['user_id'];      
  86. }
  87. function get_app_token($user_json){//解析user_json,获取app_token
  88.     $json = json_decode($user_json,true);
  89.     return $json['token_info']['app_token'];        
  90. }
  91. //取出文本中间文本
  92. function GetBetween($content,$start,$end){
  93.     $r = explode($start, $content);
  94.     if (isset($r[1])){
  95.         $r = explode($end, $r[1]);
  96.         return $r[0];
  97.     }
  98.     return '';
  99. }


  100. //此应用专用curl,返回response_header
  101. function curl_sport($url,$post=0,$type=0,$request=''){//GET\POST网络请求
  102.     $ch = curl_init();
  103.     curl_setopt($ch, CURLOPT_URL,$url);
  104.     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  105.     curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
  106.     curl_setopt($ch, CURLOPT_HTTPHEADER, $httpheader);
  107.     curl_setopt($ch, CURLOPT_TIMEOUT, 10);  
  108.     if($post){
  109.         curl_setopt($ch, CURLOPT_POST, 1);
  110.         curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
  111.     }
  112.     if($request!=''){
  113.         $httpheader[] = "apptoken:".$request;
  114.         curl_setopt($ch, CURLOPT_HTTPHEADER, $httpheader);
  115.     }
  116.     //返回 response_header, 该选项非常重要,如果不为 true, 只会获得响应的正文
  117.     curl_setopt($ch, CURLOPT_HEADER, $type);
  118.     curl_setopt($ch, CURLINFO_HEADER_OUT, true);
  119.     curl_setopt($ch, CURLOPT_AUTOREFERER, false);
  120.     curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
  121.     $ret = curl_exec($ch);
  122.     curl_close($ch);
  123.     return $ret;
  124. }

  125. function strexists($string, $find) {//取字符串中是否包含指定字符串
  126.     return !(strpos($string, $find) === FALSE);
  127. }

  128. function Curl($url, $data = null, $cookie = null, $httpheader = null)
  129.     {
  130.         $curl = curl_init();
  131.         curl_setopt($curl, CURLOPT_URL, $url);
  132.         $httpheader[] = "Accept-Language: zh-CN,zh;q=0.8";
  133.         $httpheader[] = "Connection: keep-alive";
  134.         curl_setopt($curl, CURLOPT_HTTPHEADER, $httpheader);
  135.         if ($data) {
  136.             if (is_array($data)) $data = http_build_query($data);
  137.             curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
  138.             curl_setopt($curl, CURLOPT_POST, 1);
  139.         }
  140.         if($cookie){
  141.             curl_setopt($curl, CURLOPT_COOKIE, $cookie);
  142.         }
  143.         curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
  144.         curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
  145.         curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 10);
  146.         curl_setopt($curl, CURLOPT_HEADER, 1);
  147.         $ret = curl_exec($curl);
  148.         $headerSize = curl_getinfo($curl, CURLINFO_HEADER_SIZE);
  149.         $header = substr($ret, 0, $headerSize);
  150.         $content = substr($ret, $headerSize);
  151.         $ret = array();
  152.         $ret['header'] = $header;
  153.         $ret['content'] = $content;
  154.         curl_close($curl);
  155.         return $ret;
  156.     }
  157. ?>
复制代码


您需要登录后才可以回帖 登录 | 立即注册

本版积分规则 返回列表 发新帖

快速回复 返回顶部 返回列表