Skip to content

Commit

Permalink
Merge pull request #13 from bryanisimo/patch-1
Browse files Browse the repository at this point in the history
Update README.md
  • Loading branch information
artdarek committed Oct 16, 2013
2 parents de66a45 + 3d5af70 commit 90cb02a
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,61 @@ public function loginWithGoogle() {
}
}
```



###Linkedin:

Configuration:
Add your Linkedin credentials to ``app/config/packages/artdarek/oauth-4-laravel/config.php``

```php
'Linkedin' => array(
'client_id' => 'Your Linkedin API ID',
'client_secret' => 'Your Linkedin API Secret',
),
```
In your Controller use the following code:

```php

public function loginWithLinkedin() {

// get data from input
$code = Input::get( 'code' );

$linkedinService = OAuth::consumer( 'Linkedin' );


if ( !empty( $code ) ) {

// This was a callback request from linkedin, get the token
$token = $linkedinService->requestAccessToken( $code );
// Send a request with it. Please note that XML is the default format.
$result = json_decode($linkedinService->request('/people/~?format=json'), true);

// Show some of the resultant data
echo 'Your linkedin first name is ' . $result['firstName'] . ' and your last name is ' . $result['lastName'];


//Var_dump
//display whole array().
dd($result);

}// if not ask for permission first
else {
// get linkedinService authorization
$url = $linkedinService->getAuthorizationUri(array('state'=>'DCEEFWF45453sdffef424'));

// return to linkedin login url
return Response::make()->header( 'Location', (string)$url );
}


}

```

### More usage examples:

For examples go [here](https://github.com/Lusitanian/PHPoAuthLib/tree/master/examples)
Expand Down

0 comments on commit 90cb02a

Please sign in to comment.