Steam第三方登錄

Steam第三方登錄

Laravel PHP7.3

前端登錄界面

<li class="sc-st">
    <a class="animate"  href="?steam_login">
        <img src="/images/info-icon-steam.png" alt="Steam" title="Login With Steam">
    </a>
</li> 

@if(isset($steamprofile))
<script type="text/javascript">
window.onload=function(){
    var steamprofile = '{!!$steamprofile!!}';
    var steamid = '{{$steamid}}';
    if(steamid){
        $.post('/ajax/SocilaAuthLogin',{
            data:{userdata:steamprofile,type:'steamLogin'},
            },function(data){
                var data=JSON.parse(data);
                art.dialog({
                    title:'{{$LANG['PUBLIC']['TIPS']}}',
                    icon: data['icon'],
                    content:data['tips'],
                    okVal:'ok'
                });  
                window.location.reload();       
        });
    }
} 
</script>
@endif

控制器代碼

<?php

namespace App\Http\Controllers;
use Illuminate\Support\Facades\Log;
use Illuminate\Http\Request;
use DB;
use Illuminate\Support\Facades\Validator;
use Illuminate\Support\Facades\Session;
use App\Http\Models\Website\TwitterThirdLogin;
use Route;
use Illuminate\Pagination\LengthAwarePaginator;
use Illuminate\Support\Collection;
use App\Http\Models\Website\Basesite;
use Illuminate\Support\Facades\Input;
use Storage;

class HomeController extends Controller
{ 
    public function signin(request $request){
        //已登錄用戶跳轉(zhuǎn)登錄和注冊頁時跳轉(zhuǎn)首頁
        if(isset($this->data['member']['memberId'])){
            return redirect("/");
        }
        if (isset($_GET['steam_login'])){  
            //steam第三方
            @require_once dirname(__FILE__) . '/../../../public/plugins/steamauth/steamauth.php';
        }
        if(isset($_SESSION['steamid'])) 
        {
            @require_once dirname(__FILE__) . '/../../../public/plugins/steamauth/userInfo.php';
            $this->data['steamid']=$steamprofile['steamid'];
            $this->data['steamprofile']=json_encode($steamprofile,true);
        }    
        return view('u7buy.signin')
            ->with($this->data);
    }
}

只需要引用steam文件https://github.com/DLXXKJ/steamThridLogin.git

下載到對應(yīng)目錄中例如再steamConfig.php中 填寫steam開發(fā)這行好的key和回調(diào)地址

(steam開發(fā)者賬號申請https://steamcommunity.com/login/home/

<?php
    //Version 4.0
    $steamauth['apikey'] = "XXXXXXXX"; // Your Steam WebAPI-Key found at https://steamcommunity.com/dev/apikey
    $steamauth['domainname'] = "XXXXXXXX"; // The main URL of your website displayed in the login page
    $steamauth['logoutpage'] = ""; // Page to redirect to after a successfull logout (from the directory the SteamAuth-folder is located in) - NO slash at the beginning!
    $steamauth['loginpage'] = ""; // Page to redirect to after a successfull login (from the directory the SteamAuth-folder is located in) - NO slash at the beginning!

    // System stuff
    if (empty($steamauth['apikey'])) {die("<div style='display: block; width: 100%; background-color: red; text-align: center;'>SteamAuth:<br>Please supply an API-Key!<br>Find this in steamauth/SteamConfig.php, Find the '<b>\$steamauth['apikey']</b>' Array. </div>");}
    if (empty($steamauth['domainname'])) {$steamauth['domainname'] = $_SERVER['SERVER_NAME'];}
    if (empty($steamauth['logoutpage'])) {$steamauth['logoutpage'] = $_SERVER['PHP_SELF'];}
    if (empty($steamauth['loginpage'])) {$steamauth['loginpage'] = $_SERVER['PHP_SELF'];}
?>
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容