Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

class 'Vinkla\Pusher\Facades\Pusher' does not have a method 'socket_auth' #17

Closed
clementbirkle opened this issue Aug 18, 2016 · 10 comments

Comments

@clementbirkle
Copy link

Hello,

I don't arrive to implementing the auth endpoint for a private channel. The response is: class 'Vinkla\Pusher\Facades\Pusher' does not have a method 'socket_auth'

My code:

class UserController extends Controller
{
    protected $pusher;

    public function __construct(PusherManager $pusher)
    {
        $this->pusher = $pusher;
    }

    public function getAuthPusher()
    {
        $auth = $this->pusher->socket_auth($_POST['channel_name'], $_POST['socket_id']);
    }
}

Thank you for your help :)

@GrahamCampbell
Copy link
Contributor

It has a __call method.

@clementbirkle
Copy link
Author

Thanks for your quick response! Can you give me an example please ?

@GrahamCampbell
Copy link
Contributor

No, just call the method?

@GrahamCampbell
Copy link
Contributor

It doesn't need to exist to be called.

@clementbirkle
Copy link
Author

I do not understand how to call the method "socket_auth".
I try: $auth = $this->pusher->socket_auth;

@GrahamCampbell
Copy link
Contributor

Should work just fine?

@clementbirkle
Copy link
Author

No, it does not work: 'ErrorException' with message 'Undefined property: Vinkla\Pusher\PusherManager::$socket_auth'

Finally I found a solution ... less clean but it works:

    public function getAuthPusher(Request $request)
    {
        $this->validate($request, [
            'channel_name' => 'required',
            'socket_id' => 'required',
        ]);

        $options = array(
            'cluster' => config('pusher.connections.main.options.cluster'),
            'encrypted' => config('pusher.connections.main.options.encrypted')
        );
        $pusher = new \Pusher(
            config('pusher.connections.main.auth_key'),
            config('pusher.connections.main.secret'),
            config('pusher.connections.main.app_id'),
            $options
        );


        $auth = $pusher->socket_auth($request->channel_name, $request->socket_id);

        ...
    }

@GrahamCampbell
Copy link
Contributor

No, it does not work: 'ErrorException' with message 'Undefined property: Vinkla\Pusher\PusherManager::$socket_auth'

You need to call with with paramaters, instead of using property access. Your code there is not right.

@GrahamCampbell
Copy link
Contributor

$this->pusher->socket_auth($request->channel_name, $request->socket_id);

That there WILL work just fine.

@clementbirkle
Copy link
Author

I just found the problem !!

I added the alias 'Pusher' => Vinkla\Pusher\Facades\Pusher::class,
I removed it and it works now :)

Thanks for your help !

@vinkla vinkla closed this as completed Aug 18, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants