public getRequestToken ( String $oauth_callback = null ) | ||
$oauth_callback | String | [Optional] The callback provided for Twitter's API. The user will be redirected there after authorizing your app on Twitter. |
public function getRequestToken($oauth_callback = null)
{
$parameters = [];
if (!empty($oauth_callback)) {
$parameters['oauth_callback'] = $oauth_callback;
}
parent::request('GET', parent::url($this->tconfig['REQUEST_TOKEN_URL'], ''), $parameters);
$response = $this->response;
if (isset($response['code']) && $response['code'] == 200 && !empty($response)) {
$get_parameters = $response['response'];
$token = [];
parse_str($get_parameters, $token);
}
// Return the token if it was properly retrieved
if (isset($token['oauth_token'], $token['oauth_token_secret'])) {
return $token;
} else {
throw new Exception($response['response'], $response['code']);
}
}
/** * Get a request_token from Twitter * * @param String $oauth_callback [Optional] The callback provided for Twitter's API. The user will be redirected there after authorizing your app on Twitter. * @returns Array|Bool a key/value array containing oauth_token and oauth_token_secret in case of success * @static */ public static function getRequestToken($oauth_callback = null) { return \Thujohn\Twitter\Twitter::getRequestToken($oauth_callback); }