| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- <?php
- namespace app\api\controller\v2;
- use app\api\controller\Api;
- use app\common\library\DyGameOpen;
- /**
- * 第三方对接管理
- */
- class Third extends Api
- {
- // 抖音 code 换取 access_token
- public function getDyCode(){
- $code = $this->input('code');
- $game_id = $this->input('gameid');
- if(empty($code) || empty($game_id)){
- $this->jsonResult('', 0, '非法请求,缺少必要参数!');
- }
- try{
- $dyResult = (new DyGameOpen($game_id, 'game_id'))->getAccessToken($code);
- if($dyResult['code'] != 100){
- $this->jsonResult([], 0, $dyResult['msg']);
- }
- }catch (\Exception $e){
- $this->jsonResult([], 0, "error: ".$e->getMessage());
- }
- $this->jsonResult($dyResult['data'], 1, 'success');
- }
- // 抖音 查询绑定意愿
- public function getDyAuthInfoOpen(){
- $open_id = $this->input['open_id'];
- $game_id = $this->input('gameid');
- if(empty($open_id) || empty($game_id)){
- $this->jsonResult('', 0, '非法请求,缺少必要参数!');
- }
- try{
- $result = (new DyGameOpen($game_id, 'game_id'))->getAuthInfoOpen($open_id);
- if($result['code'] != 100){
- $this->jsonResult([], 0, $result['msg']);
- }
- }catch (\Exception $e){
- $this->jsonResult([], 0, "error: ".$e->getMessage());
- }
- $this->jsonResult($result['data'], 1, 'success');
- }
- // 抖音 游戏内授权后回调抖音游戏
- public function getJumpAuthCallback(){
- $is_agree = $this->input['is_agree'];
- $scheme = $this->input['scheme'];
- $username = $this->input['username'];
- $game_id = $this->input('game_id');
- if(empty($is_agree) || empty($scheme) || empty($username) || empty($game_id)){
- $this->jsonResult([], 0, '非法请求,缺少必要参数!');
- }
- try{
- $result = (new DyGameOpen($game_id, 'game_id'))->getJumpAuthCallback($is_agree, $username, $scheme);
- if($result['code'] != 100){
- $this->jsonResult([], 0, $result['msg']);
- }
- }catch (\Exception $e){
- $this->jsonResult([], 0, "error: ".$e->getMessage());
- }
- $this->jsonResult($result['data'], 1, 'success');
- }
- }
|