我正在用Laravel 5制作一个Live应用程序,我正在学习本教程,https://github.com/dazzz1er/confer/tree/master我已经跟踪了所有这些内容,但是我的网络控制台出现了一个错误:

它似乎是在我的url /public/index.php/auth上进行ajax调用,而且由于我没有处理该请求的路径,它说404。我不知道是否应该为它制定一条路线,但我应该在那里编码什么呢?我没有头绪。本教程甚至没有提到它。
谢谢
发布于 2015-05-22 12:36:06
每当您调用Auth::check()时,Laravel将通过检查其会话信息来验证用户是否经过身份验证。
那Pusher呢?他们如何知道,哪些用户目前登录到您的laravel应用程序?
答案在于ajax调用http://localhost/joene_/public/index.php/auth。
通过调用上面的URL,您的laravel安装将允许您的Pusher应用程序链接到您的用户的laravel会话。
让我们深入研究一些代码:
1)推土机Auth控制器
class PusherController extends Controller {
//accessed through '/pusher/'
//setup your routes.php accordingly
public function __construct() {
parent::__construct();
//Let's register our pusher application with the server.
//I have used my own config files. The config keys are self-explanatory.
//You have received these config values from pusher itself, when you signed up for their service.
$this->pusher = new Pusher(\Config::get('pusher.app_key'), \Config::get('pusher.app_secret'), \Config::get('pusher.app_id'));
}
/**
* Authenticates logged-in user in the Pusher JS app
* For presence channels
*/
public function postAuth()
{
//We see if the user is logged in our laravel application.
if(\Auth::check())
{
//Fetch User Object
$user = \Auth::user();
//Presence Channel information. Usually contains personal user information.
//See: https://pusher.com/docs/client_api_guide/client_presence_channels
$presence_data = array('name' => $user->first_name." ".$user->last_name);
//Registers users' presence channel.
echo $this->pusher->presence_auth(Input::get('channel_name'), Input::get('socket_id'), $user->id, $presence_data);
}
else
{
return Response::make('Forbidden',403);
}
}
}2)与推土机配套使用的JS
//replace 'xxx' below with your app key
var pusher = new Pusher('xxx',{authEndpoint : '/pusher/auth'});
var presenceChannelCurrent = pusher.subscribe('presence-myapp');
presenceChannelCurrent.bind('pusher:subscription_succeeded', function() {
alert(presenceChannelCurrent.members.me.info.name+' has successfully subscribed to the Pusher Presence Channel - My App');
});希望它能帮到你。
https://stackoverflow.com/questions/30395219
复制相似问题