Skip to content

Commit

Permalink
Merge pull request mautic#35 from hideokamoto/readme-add-try-catch
Browse files Browse the repository at this point in the history
add try - catch for auth sample code
  • Loading branch information
alanhartless authored Jun 23, 2016
2 parents eb3b77b + 8a7d0a1 commit bf8e4af
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,20 +54,24 @@ $auth = ApiAuth::initiate($settings);

// If the access token is expired, and a refresh token is set above, then a new access token will be requested

if ($auth->validateAccessToken()) {

// Obtain the access token returned; call accessTokenUpdated() to catch if the token was updated via a
// refresh token

// $accessTokenData will have the following keys:
// For OAuth1.0a: access_token, access_token_secret, expires
// For OAuth2: access_token, expires, token_type, refresh_token

if ($auth->accessTokenUpdated()) {
$accessTokenData = $auth->getAccessTokenData();

//store access token data however you want
try {
if ($auth->validateAccessToken()) {

// Obtain the access token returned; call accessTokenUpdated() to catch if the token was updated via a
// refresh token

// $accessTokenData will have the following keys:
// For OAuth1.0a: access_token, access_token_secret, expires
// For OAuth2: access_token, expires, token_type, refresh_token

if ($auth->accessTokenUpdated()) {
$accessTokenData = $auth->getAccessTokenData();

//store access token data however you want
}
}
} catch (Exception $e) {
// Do Error handling
}
```

Expand Down

0 comments on commit bf8e4af

Please sign in to comment.