JorgenPhi / php-snapchat

A PHP library for the Snapchat API - With Commit History
MIT License
259 stars 73 forks source link

Keeping user logged in throughout multiple pages? #32

Closed martynball closed 10 years ago

martynball commented 10 years ago

This isn't really an issue with the API, but how would one go about keeping the use logged in throughout multiple pages? It creates an object when you login which is needed to fetch snaps, but if I pass that on using a session variable it messes the object up.

And I can't convert it to a array as the other functions like getSnaps() need it in object form! There are also sub-objects which mess up.

Anyone got any example code they would use to pass the object on or keep the user logged in? I want to use some Ajax to fetch recent snaps ect...

dprogramming commented 10 years ago

You can also store the auth_token and username somewhere so you can use that to get the snaps later on without the need to sign in again.

martynball commented 10 years ago

How do I use the auth_token instead of using the $snapchat object?

dprogramming commented 10 years ago

That token confirms to Snapchat that it's an ongoing session...

martynball commented 10 years ago

I don't understand... when I login it creates an object called $snapchat, and then you use this object to get snaps, for example $snapchat->getSnaps();

But now if I was to navigate to another page that object is gone, unless I create it again using: $snapchat = new Snapchat('username', 'password');

So how would I use the auth_token to fetch snaps ect without the need of that object?

martynball commented 10 years ago

ive got it now after looking at the code! my bad!

$snapchat = new Snapchat('username', '' ,'auth_token');