Abraham\TwitterOAuth\TwitterOAuth::oauth PHP Method

oauth() public method

Make /oauth/* requests to the API.
public oauth ( string $path, array $parameters = [] ) : array
$path string
$parameters array
return array
    public function oauth($path, array $parameters = [])
    {
        $response = [];
        $this->resetLastResponse();
        $this->response->setApiPath($path);
        $url = sprintf('%s/%s', self::API_HOST, $path);
        $result = $this->oAuthRequest($url, 'POST', $parameters);
        if ($this->getLastHttpCode() != 200) {
            throw new TwitterOAuthException($result);
        }
        parse_str($result, $response);
        $this->response->setBody($response);
        return $response;
    }

Usage Example

Esempio n. 1
0
 /**
  * Generate an access token (oauth token and oauth secret) from Twitter OAuth
  *
  * @param string $oauth_token
  * @param string $oauth_verifier
  * @return array
  * @throws \Exception
  */
 protected function getAccessToken($oauth_token, $oauth_verifier)
 {
     $data_token = $this->client->oauth('oauth/access_token', array('oauth_verifier' => $oauth_verifier, 'oauth_token' => $oauth_token));
     if (!array_key_exists('oauth_token', $data_token) || !array_key_exists('oauth_token_secret', $data_token)) {
         throw new \Exception("OAuth token not confirmed");
     }
     return $data_token;
 }
All Usage Examples Of Abraham\TwitterOAuth\TwitterOAuth::oauth