duellsy/pockpack — pull request #15 by dietervds (2013-10-29 16:06:05+00:00)
Title: Added retrieval of Pocket username when exchanging a request token

When retrieving the user access token, by using the request token and the consumer key, the Pocket response also includes the Pocket username. Right now that username isn't returned.
This PR adds an extra function which you can use if you're interesting in that username.

This can be useful to have when you're building 'login with pocket' functionality, since you need something with which you can identify the authenticating user. Since the user access token can change (I assume), you'll have to store the Pocket username in the database to know if you've seen this person logging in before.

I'm keeping the existing receiveToken($consumer_key, $request_token) signature the same for compatibility with existing code, I just added a receiveTokenAndUsername function, and made a private function which bundles the common code.

If there is anything wrong with the PR, even just styling-wise, don't hesitate the criticise, this is my first actual PR to someone else's public repository :-)