PHP Interface Happyr\LinkedIn\LinkedInInterface

Author: Tobias Nyholm ([email protected])
Show file Open project: happyr/linkedin-api-client

Public Methods

Method Description
api ( string $method, string $resource, array $options = [] ) : mixed Make an API call. Read about what calls that are possible here: https://developer.linkedin.com/docs/rest-api.
clearStorage ( ) Clear the data storage. This will forget everything about the user and authentication process.
get ( string $resource, array $options = [] ) : mixed See docs for LinkedIn::api().
getAccessToken ( ) : Happyr\LinkedIn\AccessToken | null Returns an access token. If we do not have one in memory, try to fetch one from a *code* in the $_REQUEST.
getError ( ) : Happyr\LinkedIn\Exception\LoginError | null Returns a LoginError or null.
getLastResponse ( ) : Psr\Http\Message\ResponseInterface | null Get the last response. This will always return a PSR-7 response no matter of the data type used.
getLoginUrl ( array $options = [] ) : string Get a login URL where the user can put his/hers LinkedIn credentials and authorize the application.
hasError ( ) : boolean If the user has canceled the login we will return with an error.
isAuthenticated ( ) : boolean Is the current user authenticated?
post ( string $resource, array $options = [] ) : mixed See docs for LinkedIn::api().
setAccessToken ( string | Happyr\LinkedIn\AccessToken $accessToken ) If you have stored a previous access token in a storage (database) you could set it here. After setting an access token you have to make sure to verify it is still valid by running LinkedIn::isAuthenticated.
setFormat ( string $format ) Set the default format to use when sending requests.
setHttpClient ( Http\Client\HttpClient $client ) Set a http client.
setHttpMessageFactory ( Http\Message\MessageFactory $factory ) Set a http message factory.
setResponseDataType ( string $responseDataType ) Set the default data type to be returned as a response.
setStorage ( Happyr\LinkedIn\Storage\DataStorageInterface $storage ) Set a data storage.
setUrlGenerator ( Happyr\LinkedIn\Http\UrlGeneratorInterface $urlGenerator ) Set a URL generator.

Method Details

api() public method

Example: $linkedIn->api('GET', '/v1/people/~:(id,firstName,lastName,headline)'); The options: - body: the body of the request - format: the format you are using to send the request - headers: array with headers to use - response_data_type: the data type to get back - query: query parameters to the request
public api ( string $method, string $resource, array $options = [] ) : mixed
$method string This is the HTTP verb
$resource string everything after the domain in the URL.
$options array See the readme for option description.
return mixed this depends on the response_data_type parameter.

clearStorage() public method

Clear the data storage. This will forget everything about the user and authentication process.
public clearStorage ( )

get() public method

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

getAccessToken() public method

Returns an access token. If we do not have one in memory, try to fetch one from a *code* in the $_REQUEST.
public getAccessToken ( ) : Happyr\LinkedIn\AccessToken | null
return Happyr\LinkedIn\AccessToken | null The access token of null if the access token is not found

getError() public method

Returns a LoginError or null.
public getError ( ) : Happyr\LinkedIn\Exception\LoginError | null
return Happyr\LinkedIn\Exception\LoginError | null

getLastResponse() public method

Get the last response. This will always return a PSR-7 response no matter of the data type used.
public getLastResponse ( ) : Psr\Http\Message\ResponseInterface | null
return Psr\Http\Message\ResponseInterface | null

getLoginUrl() public method

The options: - redirect_uri: the url to go to after a successful login - scope: comma (or space) separated list of requested extended permissions
public getLoginUrl ( array $options = [] ) : string
$options array Provide custom parameters
return string The URL for the login flow

hasError() public method

If the user has canceled the login we will return with an error.
public hasError ( ) : boolean
return boolean

isAuthenticated() public method

Is the current user authenticated?
public isAuthenticated ( ) : boolean
return boolean

post() public method

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

setAccessToken() public method

If you have stored a previous access token in a storage (database) you could set it here. After setting an access token you have to make sure to verify it is still valid by running LinkedIn::isAuthenticated.
public setAccessToken ( string | Happyr\LinkedIn\AccessToken $accessToken )
$accessToken string | Happyr\LinkedIn\AccessToken

setFormat() public method

Set the default format to use when sending requests.
public setFormat ( string $format )
$format string

setHttpClient() public method

Set a http client.
public setHttpClient ( Http\Client\HttpClient $client )
$client Http\Client\HttpClient

setHttpMessageFactory() public method

Set a http message factory.
public setHttpMessageFactory ( Http\Message\MessageFactory $factory )
$factory Http\Message\MessageFactory

setResponseDataType() public method

Set the default data type to be returned as a response.
public setResponseDataType ( string $responseDataType )
$responseDataType string

setStorage() public method

Set a data storage.
public setStorage ( Happyr\LinkedIn\Storage\DataStorageInterface $storage )
$storage Happyr\LinkedIn\Storage\DataStorageInterface

setUrlGenerator() public method

Set a URL generator.
public setUrlGenerator ( Happyr\LinkedIn\Http\UrlGeneratorInterface $urlGenerator )
$urlGenerator Happyr\LinkedIn\Http\UrlGeneratorInterface