0

我的应用程序控制器中有我的 app_key、密钥和密钥

我的 PusherController:

  def auth
    if current_user
      auth = Pusher[params[:channel_name]].authenticate(params[:socket_id],
        :user_id => current_user.id, # => required
        :user_info => { # => optional
          :name => current_user.name,
          :email => current_user.email
        }
      )
      render :json => auth
    else
      render :text => "Not authorized", :status => '403'
    end
  end

我的js

var pusher = new Pusher("key");
Pusher.channel_auth_endpoint = "/pusher/auth";
Pusher.channel_auth_transport = 'json';

channel = pusher.subscribe("presence-content_editing");

我很确定我遵循了http://pusher.com/docs/presence-1.6的说明

Nwo 我只是对为什么会收到此错误感到困惑

this is the error :
Uncaught TypeError: Cannot call method 'scopedTo' of undefined
Pusher.Channel.PrivateChannel.authorizepusher.min.js:38
Pusher.subscribepusher.min.js:13
Pusher.subscribeAllpusher.min.js:12
connection.bind.bind.cpusher.min.js:10
a.emitpusher.min.js:17
jpusher.min.js:25
_machine.b.Machine.connectedPostpusher.min.js:29
apusher.min.js:19
c.transitionpusher.min.js:20
w
4

2 回答 2

1

删除这两行:

Pusher.channel_auth_endpoint = "/pusher/auth";
Pusher.channel_auth_transport = 'json';
于 2012-01-31T22:25:43.193 回答
0

Presence资源看起来已过时 - 我们需要将其删除。

您应该使用最新版本的 Pusher JavaScript 库,您可以在此处找到:

http://js.pusher.com/1.11/pusher.min.js

并遵循身份验证用户文档中概述的身份验证。您拥有的服务器代码看起来不错。错误出现在您的客户端上,我希望更新 JavaScript 库可以解决它 - 我们没有收到任何关于此问题的支持请求。

于 2012-01-31T19:19:57.887 回答