将Parse与Pusher集成

时间:2015-08-01 07:37:43

标签: android parse-platform real-time access-token pusher

根据Pusher docs,对于订阅私人频道的客户,他需要经过一些授权过程。有人可以指导我如何使用Parse来实现这一目标吗?我已经为我的Android应用程序集成了Facebook登录和Parse。我不太熟悉Web开发代码,所以很难理解这个

  

HttpAuthorizer authorizer = new HttpAuthorizer(http://example.com/some_auth_endpoint);   PusherOptions options = new PusherOptions()。setAuthorizer(authorizer);

     

Pusher pusher = new Pusher(YOUR_APP_KEY,期权);

1 个答案:

答案 0 :(得分:0)

有人编写了一个提供身份验证功能的Parse模块:https://github.com/kashif/pusher-parse

README的auth示例是:

app.post('/authorise', function(req, res) {
  var socketId = req.body.socket_id;
  var channel = req.body.channel_name;
  var user_id = channel.split("-")[1];

  var user = Parse.Object.extend("User");
  var query = new Parse.Query(user);
  query.get(user_id, {
    success: function(userAgain) {
        var presenceData = {
          user_id: userAgain.id,
          user_info: {
            username: userAgain.get("username"),
            email: userAgain.get("email")
          }
        };
        var auth = pusher.authenticate( socketId, channel, presenceData );
        res.send(auth);
    },
    error: function(model, error) {
      res.status(403);
      res.send('Forbidden');
    }
  });
});