Example #1
0
 /**
  * Get honest-to-goodness user data.
  */
 private function fetchData()
 {
     try {
         $msgParams = OAuthUtil::isFormEncoded($this->realRequest->getContentType()) ? OAuthUtil::urldecodeRFC3986($this->realRequest->getPostBody()) : array();
         $method = $this->realRequest->getMethod();
         $msgParams[self::$XOAUTH_APP_URL] = $this->authToken->getAppUrl();
         // Build and sign the message.
         $oauthRequest = $this->newRequestMessageMethod($method, $this->realRequest->getUrl(), $msgParams);
         $rcr = $this->createRemoteContentRequest($this->filterOAuthParams($oauthRequest), $this->realRequest->getMethod(), $this->realRequest->getUrl(), $this->realRequest->getHeaders(), $this->realRequest->getContentType(), $this->realRequest->getPostBody(), $this->realRequest->getOptions());
         $content = $this->getNextFetcher()->fetchRequest($rcr);
         //TODO is there a better way to detect an SP error?
         $statusCode = $content->getHttpCode();
         if ($statusCode >= 400 && $statusCode < 500) {
             $message = $this->parseAuthHeader(null, $content);
             if ($message->get_parameter(OAuth::$OAUTH_PROBLEM) != null) {
                 throw new OAuthProtocolException($message);
             }
         }
         // Track metadata on the response
         $this->addResponseMetadata();
         return $content;
     } catch (Exception $e) {
         throw new GadgetException("INTERNAL SERVER ERROR: " . $e);
     }
 }