PHP Class Happyr\LinkedIn\LinkedIn

When a new user arrives and want to authenticate here is whats happens: 1. You redirect him to whatever url getLoginUrl() returns. 2. The user logs in on www.linkedin.com and authorize your application. 3. The user returns to your site with a *code* in the the $_REQUEST. 4. You call isAuthenticated() or getAccessToken() 5. If we don't have an access token (only a *code*), getAccessToken() will call fetchNewAccessToken() 6. fetchNewAccessToken() gets the *code* from the $_REQUEST and calls getAccessTokenFromCode() 7. getAccessTokenFromCode() makes a request to www.linkedin.com and exchanges the *code* for an access token 8. When you have the access token you should store it in a database and/or query the API. 9. When you make a second request to the API we have the access token in memory, so we don't go through all these authentication steps again.
Author: Tobias Nyholm ([email protected])
Inheritance: implements Happyr\LinkedIn\LinkedInInterface
Afficher le fichier Open project: happyr/linkedin-api-client Class Usage Examples

Protected Properties

Свойство Type Description
$accessToken Happyr\LinkedIn\AccessToken The OAuth access token received in exchange for a valid authorization code. null means the access token has yet to be determined.

Méthodes publiques

Méthode Description
__construct ( string $appId, string $appSecret, string $format = 'json', string $responseDataType = 'array' ) Constructor.
api ( $method, $resource, array $options = [] )
clearStorage ( )
get ( string $resource, array $options = [] ) : mixed See docs for LinkedIn::api().
getAccessToken ( )
getError ( )
getLastResponse ( )
getLoginUrl ( $options = [] )
hasError ( )
isAuthenticated ( )
post ( string $resource, array $options = [] ) : mixed See docs for LinkedIn::api().
setAccessToken ( $accessToken )
setFormat ( $format )
setHttpClient ( Http\Client\HttpClient $client )
setHttpMessageFactory ( Http\Message\MessageFactory $factory )
setResponseDataType ( $responseDataType )
setStorage ( Happyr\LinkedIn\Storage\DataStorageInterface $storage )
setUrlGenerator ( Happyr\LinkedIn\Http\UrlGeneratorInterface $urlGenerator )

Méthodes protégées

Méthode Description
filterRequestOption ( array &$options ) : string Modify and filter the request options. Make sure we use the correct query parameters and headers.
getAuthenticator ( ) : Authenticator
getFormat ( ) : string Get the default format to use when sending requests.
getRequestManager ( ) : RequestManager
getResponseDataType ( ) : string Get the default data type to be returned as a response.
getUrlGenerator ( ) : Happyr\LinkedIn\Http\UrlGeneratorInterface

Method Details

__construct() public méthode

Constructor.
public __construct ( string $appId, string $appSecret, string $format = 'json', string $responseDataType = 'array' )
$appId string
$appSecret string
$format string 'json', 'xml'
$responseDataType string 'array', 'string', 'simple_xml' 'psr7', 'stream'

api() public méthode

public api ( $method, $resource, array $options = [] )
$options array

clearStorage() public méthode

public clearStorage ( )

filterRequestOption() protected méthode

Modify and filter the request options. Make sure we use the correct query parameters and headers.
protected filterRequestOption ( array &$options ) : string
$options array
Résultat string the request format to use

get() public méthode

See docs for LinkedIn::api().
public get ( string $resource, array $options = [] ) : mixed
$resource string
$options array
Résultat mixed

getAccessToken() public méthode

public getAccessToken ( )

getAuthenticator() protected méthode

protected getAuthenticator ( ) : Authenticator
Résultat Authenticator

getError() public méthode

public getError ( )

getFormat() protected méthode

Get the default format to use when sending requests.
protected getFormat ( ) : string
Résultat string

getLastResponse() public méthode

public getLastResponse ( )

getLoginUrl() public méthode

public getLoginUrl ( $options = [] )

getRequestManager() protected méthode

protected getRequestManager ( ) : RequestManager
Résultat Happyr\LinkedIn\Http\RequestManager

getResponseDataType() protected méthode

Get the default data type to be returned as a response.
protected getResponseDataType ( ) : string
Résultat string

getUrlGenerator() protected méthode

protected getUrlGenerator ( ) : Happyr\LinkedIn\Http\UrlGeneratorInterface
Résultat Happyr\LinkedIn\Http\UrlGeneratorInterface

hasError() public méthode

public hasError ( )

isAuthenticated() public méthode

public isAuthenticated ( )

post() public méthode

See docs for LinkedIn::api().
public post ( string $resource, array $options = [] ) : mixed
$resource string
$options array
Résultat mixed

setAccessToken() public méthode

public setAccessToken ( $accessToken )

setFormat() public méthode

public setFormat ( $format )

setHttpClient() public méthode

public setHttpClient ( Http\Client\HttpClient $client )
$client Http\Client\HttpClient

setHttpMessageFactory() public méthode

public setHttpMessageFactory ( Http\Message\MessageFactory $factory )
$factory Http\Message\MessageFactory

setResponseDataType() public méthode

public setResponseDataType ( $responseDataType )

setStorage() public méthode

public setStorage ( Happyr\LinkedIn\Storage\DataStorageInterface $storage )
$storage Happyr\LinkedIn\Storage\DataStorageInterface

setUrlGenerator() public méthode

public setUrlGenerator ( Happyr\LinkedIn\Http\UrlGeneratorInterface $urlGenerator )
$urlGenerator Happyr\LinkedIn\Http\UrlGeneratorInterface

Property Details

$accessToken protected_oe property

The OAuth access token received in exchange for a valid authorization code. null means the access token has yet to be determined.
protected AccessToken,Happyr\LinkedIn $accessToken
Résultat Happyr\LinkedIn\AccessToken