/** * * @throws GadgetException */ private function fetchRequestToken(RemoteContentRequest $request) { try { $accessor = $this->accessorInfo->getAccessor(); //TODO The implementations of oauth differs from the one in JAVA. Fix the type OAuthMessage $url = $accessor->consumer->callback_url->requestTokenURL; $msgParams = array(); self::addIdentityParams($msgParams, $request->getToken()); $callbackState = new OAuthCallbackState($this->oauthCrypter); $callbackUrl = "http://" . getenv('HTTP_HOST') . "/gadgets/oauthcallback"; $callbackState->setRealCallbackUrl($callbackUrl); $cs = $callbackState->getEncryptedState(); $msgParams[self::$OAUTH_CALLBACK] = $callbackUrl . "?cs=" . urlencode($cs); $request = $this->newRequestMessageParams($url->url, $msgParams); $reply = $this->sendOAuthMessage($request); $reply->requireParameters(array(ShindigOAuth::$OAUTH_TOKEN, ShindigOAuth::$OAUTH_TOKEN_SECRET)); $accessor->requestToken = $reply->get_parameter(ShindigOAuth::$OAUTH_TOKEN); $accessor->tokenSecret = $reply->get_parameter(ShindigOAuth::$OAUTH_TOKEN_SECRET); } catch (Exception $e) { // It's unfortunate the OAuth libraries throw a generic Exception. throw new GadgetException($e); } }