jdolitsky / AppDotNetPHP

PHP library for the App.net Stream API
34 stars 19 forks source link

Set user's username [suggestion] #17

Closed edent closed 12 years ago

edent commented 12 years ago

It would be great if the user's username was set (either in GLOBAL, _SESSION, or in the cookie).

That makes it easier to spot if a post is a reply, can be deleted, etc.

ravisorg commented 12 years ago

You can use $app->getUser() to pull all the information for the user. And inside that object is the username.

eg:

$user = $app->getUser();
print $user['username'];
edent commented 12 years ago

Oh, sure, but it's an extra API call.

ravisorg commented 12 years ago

That's the only way we would be able to (securely) get the information as well. You would not be able to assume that the username would be consistent between sessions (users can, and do, change their usernames).

That said, if you wanted to store it during a single session you could easily do:

$user = $app->getUser();
$_SESSION['app_username'] = $user['username'];

And then access it from there on subsequent page loads.

edent commented 12 years ago

That's an excellent point - thanks.