Skip to content

Commit

Permalink
changed readme text
Browse files Browse the repository at this point in the history
  • Loading branch information
dirkgroenen committed Dec 18, 2015
1 parent adc8864 commit 8e7a6b2
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,15 @@ echo '<a href=' . $loginurl . '>Authorize Pinterest</a>';

Check the [Pinterest documentation](https://dev.pinterest.com/docs/api/overview/#scopes) for the available scopes.

After your user has used the login link to authorize he will be send back to the given `CALLBACK_URL`. The URL will contain the `code` which can be exchanged into an `access_token`. To exchange the code for an `access_token` and set it you can use the following code:

```php
if(isset($_GET["code"])){
$token = $pinterest->auth->getOAuthToken($_GET["code"]);
$pinterest->auth->setOAuthToken($token->access_token);
}
```

## Get the user's profile

To get the profile of the current logged in user you can use the `Users::me(<array>);` method.
Expand Down Expand Up @@ -167,15 +176,15 @@ Returns: `Boolean`
The methods below are available through `$pinterest->auth`.

### Get login URL
`getLoginUrl(string $redirect_uri, array $scopes);`
`getLoginUrl(string $redirect_uri, array $scopes, string $response_type = "code");`

```php
$pinterest->auth->getLoginUrl("https://pinterest.dev/callback.php", array("read_public"));
```

Check the [Pinterest documentation](https://dev.pinterest.com/docs/api/overview/#scopes) for the available scopes.

> At this moment the Pinterest API returns the user's `access_token` in the query string on the callback page. The documentation states that this should be a code, so the next method has been writing assuming this will be changed somewhere in the future
**Note: since 0.2.0 the default authentication method has changed to `code` instead of `token`. This means you have to exchange the returned code for an access_token.**

### Get access_token
`getOAuthToken(string $code );`
Expand Down

0 comments on commit 8e7a6b2

Please sign in to comment.