oauth2() public method

Make /oauth2/* requests to the API.
public oauth2 ( string $path, array $parameters = [] ) : array | object
$path string
$parameters array
return array | object
コード例 #1
0
 public function Oauth()
 {
     $oauth = new TwitterOAuth($this->key, $this->secret);
     $accessToken = $oauth->oauth2('oauth2/token', ['grant_type' => 'client_credentials']);
     $twitter = new TwitterOAuth($this->key, $this->secret, null, $accessToken->access_token);
     return $twitter;
 }
コード例 #2
0
ファイル: Twitter.php プロジェクト: GPierre-Antoine/projetphp
 public function refresh()
 {
     $oauth = new TwitterOAuth(\twitter\configuration::$consumerKey, \twitter\configuration::$consumerSecret);
     $accessToken = $oauth->oauth2('oauth2/token', ['grant_type' => 'client_credentials']);
     $this->twitter = new TwitterOAuth(\twitter\configuration::$consumerKey, \twitter\configuration::$consumerSecret, null, $accessToken->access_token);
     $this->update();
 }
コード例 #3
0
ファイル: TwitterOAuthTest.php プロジェクト: avassilenko/av_2
 /**
  * @depends testOauth2Token
  */
 public function testOauth2TokenInvalidate($accessToken)
 {
     $twitter = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET);
     // HACK: access_token is already urlencoded but gets urlencoded again breaking the invalidate request.
     $result = $twitter->oauth2('oauth2/invalidate_token', array('access_token' => urldecode($accessToken->access_token)));
     $this->assertEquals(200, $twitter->lastHttpCode());
     $this->assertObjectHasAttribute('access_token', $result);
     return $result;
 }
コード例 #4
0
 public function __construct($apiKey, $apiKeySecret)
 {
     $this->apiKey = $apiKey;
     $this->apiKeySecret = $apiKeySecret;
     $oauth = new TwitterOAuth($this->apiKey, $this->apiKeySecret);
     $accessToken = $oauth->oauth2('oauth2/token', ['grant_type' => 'client_credentials']);
     $this->access_token = $accessToken->access_token;
     $this->twitter = new TwitterOAuth($this->apiKey, $this->apiKeySecret, null, $this->access_token);
 }
コード例 #5
0
 public function testOauth2Token()
 {
     $twitter = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET);
     $result = $twitter->oauth2('oauth2/token', array('grant_type' => 'client_credentials'));
     $this->assertEquals(200, $twitter->getLastHttpCode());
     $this->assertObjectHasAttribute('token_type', $result);
     $this->assertObjectHasAttribute('access_token', $result);
     $this->assertEquals('bearer', $result->token_type);
     return $result;
 }
コード例 #6
0
 private function initTwitterOAuth()
 {
     if ($this->twitter != null) {
         return;
     }
     /** Creation de l'objet TwitterOAuth qui me permet de recuperer les tweets */
     $oauth = new TwitterOAuth("rC3gP2pji5zoKoGf4FlUYdvaa", "TYIpFvcb9wR6SrpdxmMCPruiyJSPSDfJdLz6cAlNgqoyMcMq2j");
     $accesstoken = $oauth->oauth2('oauth2/token', ['grant_type' => 'client_credentials']);
     $this->twitter = new TwitterOAuth("rC3gP2pji5zoKoGf4FlUYdvaa", "TYIpFvcb9wR6SrpdxmMCPruiyJSPSDfJdLz6cAlNgqoyMcMq2j", null, $accesstoken->access_token);
 }