예제 #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
 public function __construct(ServiceInterface $service)
 {
     try {
         $response = $service->request($this->userEndpoint);
     } catch (\OAuth\Common\Storage\Exception\TokenNotFoundException $e) {
         throw $e;
     } catch (\OAuth\Common\Http\Exception\TokenResponseException $e) {
         throw $e;
     } catch (\OAuth\Common\Token\Exception\ExpiredTokenException $e) {
         throw $e;
     }
     $object = $this->decodeResponse($response);
     $this->user = $this->getUserResponse($object);
 }
 /**
  * Sends an authenticated API request to the path provided.
  * If the path provided is not an absolute URI, the base API Uri (service-specific) will be used.
  *
  * @param string|UriInterface $path
  * @param string              $method       HTTP method
  * @param array               $body         Request body if applicable (an associative array will
  *                                          automatically be converted into a urlencoded body)
  * @param array               $extraHeaders Extra headers if applicable. These will override service-specific
  *                                          any defaults.
  *
  * @return string
  */
 public function request($path, $method = 'GET', $body = null, array $extraHeaders = array())
 {
     return $this->provider->request($path, $method, $body, $extraHeaders);
 }
예제 #4
0
 /**
  * Sends an authenticated API request to the path provided.
  * If the path provided is not an absolute URI, the base API Uri (service-specific) will be used.
  *
  * @param string|UriInterface $path
  * @param string              $method       HTTP method
  * @param array               $body         Request body if applicable (an associative array will
  *                                          automatically be converted into a urlencoded body)
  * @param array               $extraHeaders Extra headers if applicable. These will override service-specific
  *                                          any defaults.
  *
  * @return array                            Decoded response
  */
 public function request($path, $method = 'GET', $body = null, array $extraHeaders = array())
 {
     $this->assertServiceInstance();
     $response = $this->service->request($path, $method, $body, $extraHeaders);
     return json_decode($response, true);
 }
예제 #5
0
 /**
  * @return mixed
  */
 public function getUserData()
 {
     $result = json_decode($this->service->request('/people/~?format=json'), true);
     return $result;
 }