正在显示
1 个修改的文件
包含
24 行增加
和
2 行删除
| @@ -39,7 +39,29 @@ class Index extends Api | @@ -39,7 +39,29 @@ class Index extends Api | ||
| 39 | }else{ | 39 | }else{ |
| 40 | return $this->error("返回失败"); | 40 | return $this->error("返回失败"); |
| 41 | } | 41 | } |
| 42 | - | ||
| 43 | - | 42 | + } |
| 43 | + //获取token | ||
| 44 | + public function tokenLogin(){ | ||
| 45 | + $appKey="waterPro_54989312"; | ||
| 46 | + $appSecret="bef381707451606b34c1f9b4b18bd5d7"; | ||
| 47 | + $url="https://tyuims.tenyes.cn/api/access_token"; | ||
| 48 | + $postdata=[ | ||
| 49 | + "appKey"=>$appKey, | ||
| 50 | + "appSecret"=>$appSecret, | ||
| 51 | + ]; | ||
| 52 | + $res =HttpHelper::post($url,$postdata); | ||
| 53 | + $jsondata=json_decode($res,true); | ||
| 54 | + if($jsondata['code']==200){ | ||
| 55 | + $loginurl="https://tyuims.tenyes.cn/api/login/token"; | ||
| 56 | + $logindata=[ | ||
| 57 | + "token"=>$jsondata['data'] | ||
| 58 | + ]; | ||
| 59 | + $res =HttpHelper::post($loginurl,$logindata); | ||
| 60 | + $jsonlogin=json_decode($res,true); | ||
| 61 | + print_r($jsonlogin);return ; | ||
| 62 | + return $this->success($jsondata['msg'],$jsondata['data']); | ||
| 63 | + }else{ | ||
| 64 | + return $this->error("请求失败"); | ||
| 65 | + } | ||
| 44 | } | 66 | } |
| 45 | } | 67 | } |
-
请 注册 或 登录 后发表评论