How to get token in php

[PECL OAuth >= 0.99.1]

OAuth::getAccessTokenFetch an access token

Description

public OAuth::getAccessToken[
    string $access_token_url,
    string $auth_session_handle = ?,
    string $verifier_token = ?,
    string $http_method = ?
]: array

Parameters

access_token_url

URL to the access token API.

auth_session_handle

Authorization session handle, this parameter does not have any citation in the core OAuth 1.0 specification but may be implemented by large providers. » See ScalableOAuth for more information.

verifier_token

For service providers which support 1.0a, a verifier_token must be passed while exchanging the request token for the access token. If the verifier_token is present in $_GET or $_POST it is passed automatically and the caller does not need to specify a verifier_token [usually if the access token is exchanged at the oauth_callback URL]. » See ScalableOAuth for more information.

http_method

HTTP method to use, e.g. GET or POST.

Return Values

Returns an array containing the parsed OAuth response on success or false on failure.

Changelog

VersionDescription
PECL oauth 1.0.0 Previously returned null on failure, instead of false.
PECL oauth 0.99.9 The verifier_token parameter was added

Examples

Example #1 OAuth::getAccessToken[] example

The above example will output something similar to:

Array
[
    [oauth_token] => some_token
    [oauth_token_secret] => some_token_secret
]

See Also

  • OAuth::getLastResponse[] - Get the last response
  • OAuth::getLastResponseInfo[] - Get HTTP information about the last response
  • OAuth::setToken[] - Sets the token and secret

There are no user contributed notes for this page.

[PHP 4 >= 4.2.0, PHP 5, PHP 7, PHP 8]

token_get_allSplit given source into PHP tokens

Description

token_get_all[string $code, int $flags = 0]: array

For a list of parser tokens, see List of Parser Tokens, or use token_name[] to translate a token value into its string representation.

Parameters

code

The PHP source to parse.

flags

Valid flags:

  • TOKEN_PARSE - Recognises the ability to use reserved words in specific contexts.

Return Values

An array of token identifiers. Each individual token identifier is either a single character [i.e.: ;, ., >, !, etc...], or a three element array containing the token index in element 0, the string content of the original token in element 1 and the line number in element 2.

Examples

Example #1 token_get_all[] example

Chủ Đề