/**
  * @param string $returnUrl
  *
  * @return string
  */
 public function getLoginUrl($returnUrl)
 {
     $config = array('consumerKey' => $this->consumerKey, 'consumerSecret' => $this->consumerSecret, 'callbackUrl' => $returnUrl, 'siteUrl' => 'https://api.twitter.com/oauth', 'authorizeUrl' => 'https://api.twitter.com/oauth/authenticate');
     $httpClientOptions = array('adapter' => 'Zend\\Http\\Client\\Adapter\\Curl', 'curloptions' => array(CURLOPT_SSL_VERIFYHOST => false, CURLOPT_SSL_VERIFYPEER => false));
     $consumer = new Consumer($config);
     $consumer->setHttpClient($consumer->getHttpClient()->setOptions($httpClientOptions));
     $token = $consumer->getRequestToken();
     $tw_session = new Container('twitter');
     $tw_session->offsetSet('request_token', serialize($token));
     return $consumer->getRedirectUrl();
 }
Ejemplo n.º 2
0
 /**
  *  twitterAction
  */
 public function twitterAction()
 {
     $config = $this->getServiceLocator()->get('config')['twitter'];
     $config['callbackUrl'] = $this->url()->fromRoute('user/default', ['controller' => 'auth', 'action' => 'twitter-callback'], ['force_canonical' => true]);
     OAuth::setHttpClient(new Client(null, $config['httpClientOptions']));
     $consumer = new Consumer($config);
     $token = $consumer->getRequestToken();
     // persist the token to storage
     $container = new Container('twitter');
     $container->requestToken = serialize($token);
     // redirect the user
     $consumer->redirect();
 }
Ejemplo n.º 3
0
 public function twitterAction()
 {
     $config = array('callbackUrl' => 'http://cursozf2.local', 'consumerKey' => '6m5PRdgc8L34OHt0jl7XQ', 'consumerSecret' => 'MbrgvIa7AQRCkNaHToKGdyIfuBPlhUVKKN2fo7k', 'siteUrl' => 'https://api.twitter.com/oauth', 'authorizeUrl' => 'https://api.twitter.com/oauth/authenticate', 'requestTokenUrl' => 'https://api.twitter.com/oauth/request_token', 'accessTokenUrl' => 'https://api.twitter.com/oauth/access_token');
     $httpConfig = array('adapter' => 'Zend\\Http\\Client\\Adapter\\Socket', 'sslverifypeer' => false);
     $httpClient = new HTTPClient(null, $httpConfig);
     OAuth::setHttpClient($httpClient);
     $consumer = new Consumer($config);
     $token = null;
     if (!$token) {
         $token = $consumer->getRequestToken();
         $_SESSION['TWITTER_REQUEST_TOKEN'] = serialize($token);
         $consumer->redirect();
     }
 }
Ejemplo n.º 4
0
 public function testGetRequestTokenReturnsInstanceOfOauthTokenRequest()
 {
     $config = array('consumerKey' => '12345', 'consumerSecret' => '54321');
     $consumer = new Consumer($config);
     $token = $consumer->getRequestToken(null, null, new RequestToken48231());
     $this->assertInstanceOf('ZendOAuth\\Token\\Request', $token);
 }