Steam第三方登录
Laravel PHP7.3
前端登录界面
@if(isset($steamprofile))
window.οnlοad=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();
});
}
}
@endif
控制器代码
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){
//已登录用户跳转登录和注册页时跳转首页
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);
}
}
下载到对应目录中例如再steamConfig.php中 填写steam开发这行好的key和回调地址
//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("
Please supply an API-Key!
Find this in steamauth/SteamConfig.php, Find the '\$steamauth['apikey']' Array.
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'];}
?>