Ejemplo n.º 1
0
 public function login(Request $request)
 {
     if (!isset($_GET['code'])) {
         $authorizationUrl = "https://login.uber.com/oauth/v2/authorize";
         $params = ['response_type' => 'code', 'client_id' => env('UBER_CLIENT_ID'), 'scope' => 'profile history_lite history', 'redirect_uri' => env('UBER_REDIRECT_URI')];
         $url = Url::from($authorizationUrl)->addParams($params);
         header('Location: ' . $url);
         exit;
         // Check given state against previously stored one to mitigate CSRF attack
     } else {
         // Try to get an access token (using the authorization code grant)
         $token = $this->provider->getAccessToken('authorization_code', ['code' => $_GET['code']]);
         // Optional: Now you have a token you can look up a users profile data
         try {
             // We got an access token, let's now get the user's details
             $user = $this->provider->getResourceOwner($token);
             // Use these details to create a new profile
             $request->session()->put('uber.token', $token->getToken());
             $request->session()->put('uber.refresh_token', $token->getRefreshToken());
         } catch (Exception $e) {
             // Failed to get user details
             exit('Oh dear...');
         }
         // Use this to interact with an API on the users behalf
         //echo $token->getToken();
         return view('success');
     }
 }
Ejemplo n.º 2
0
 /**
  * 
  * @param Crawler $block
  * @return Item
  */
 public function parseItem(Crawler $block)
 {
     $item = new Item();
     if ($this->title) {
         $item->title = $block->filter($this->title)->text();
     }
     if ($this->link) {
         $node = $block->filter($this->link);
         $href = $node->attr('href');
         $item->link = Url::from($href)->absolute($this->url);
     }
     if ($this->description) {
         $node = $block->filter($this->description);
         if ($node->count()) {
             $item->description = $node->html();
         }
     }
     return $item;
 }
Ejemplo n.º 3
0
 /**
  * @dataProvider removeParamsProvider
  * @param type $expected
  * @param type $uri
  * @param array $addParams
  */
 public function testRemoveParamsAbsolute($uri, $expected, $params)
 {
     $host = 'http://domain.com' . (strncmp($expected, '/', 1) === 0 ? '' : '/');
     $url = new Url($host . $uri);
     $actual = $url->removeParams($params);
     $this->assertEquals($host . $expected, $actual);
 }