From 531e38883632e8bef5896ada5805ccb27dc1f15c Mon Sep 17 00:00:00 2001 From: Aleksey Salnikov Date: Sun, 22 Oct 2017 21:42:47 +0300 Subject: [PATCH] #9. Access token typehinting. Update Readme. --- README.md | 20 ++++++++++++++++++++ src/Client.php | 2 +- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 7dabad4..3a71881 100644 --- a/README.md +++ b/README.md @@ -96,6 +96,26 @@ To get access token use (don't forget to set redirect url) $accessToken = $client->getAccessToken($_GET['code']); ``` +#### Setting Access Token + +You can use method `LinkedIn\Client::setAccessToken()` for setting token. You have to pass +instance of `LinkedIn\AccessToken` to this method. + +```php +use LinkedIn\AccessToken; +use LinkedIn\Client; + +// instantiate the Linkedin client +$client = new Client( + 'LINKEDIN_APP_CLIENT_ID', + 'LINKEDIN_APP_CLIENT_SECRET' +); + +// set access token +$accessToken = new AccessToken($token); +$client->setAccessToken($accessToken); +``` + #### Performing API calls All API calls can be called through simple method: diff --git a/src/Client.php b/src/Client.php index 3340110..7f5fd9c 100644 --- a/src/Client.php +++ b/src/Client.php @@ -189,7 +189,7 @@ protected static function responseToArray($response) * * @return Client */ - public function setAccessToken($accessToken) + public function setAccessToken(AccessToken $accessToken) { $this->accessToken = $accessToken; return $this;