Пример #1
0
 /**
  * Twitter connect
  */
 public function connectTwitter()
 {
     if (!empty($_GET['oauth_token'])) {
         $token = $this->session->retrieveAccessToken('Twitter');
         // This was a callback request from twitter, get the token
         $this->service->requestAccessToken($_GET['oauth_token'], $_GET['oauth_verifier'], $token->getRequestTokenSecret());
         // Send a request now that we have access token
         $result = json_decode($this->service->request('account/verify_credentials.json'), true);
         return $result;
     } elseif (isset($_GET['denied'])) {
         $denied = $_GET['denied'];
         return compact('denied');
     } else {
         // extra request needed for oauth1 to request a request token :-)
         $token = $this->service->requestRequestToken();
         $url = $this->service->getAuthorizationUri(array('oauth_token' => $token->getRequestToken()));
         header('Location: ' . $url);
     }
 }
Пример #2
0
 /**
  * Redirect to the authorization page for the service
  *
  * @param   string          $provider       The name of the service
  * @param   string|null     $callbackUrl    The URL to be used for the credentials
  * @param   array|null      $scope          The scope of the access (OAuth2 only)
  * @return  \Illuminate\Http\RedirectResponse
  */
 public function authorizationRedirect($provider, $callbackUrl = null, array $scope = null)
 {
     $this->service = $this->provider($provider, $callbackUrl, $scope);
     if (is_a($this->service, '\\OAuth\\OAuth1\\Service\\AbstractService')) {
         $token = $this->service->requestRequestToken();
         $url = $this->service->getAuthorizationUri(array('oauth_token' => $token->getRequestToken()));
     } elseif (is_a($this->service, '\\OAuth\\OAuth2\\Service\\AbstractService')) {
         $url = $this->service->getAuthorizationUri();
     }
     return Redirect::to((string) $url);
 }