Ejemplo n.º 1
0
 private function _extract($response, $p)
 {
     if (preg_match($p, $response, $matches) && count($matches) >= 1) {
         return URLUtils::formURLDecode($matches[1]);
     } else {
         throw new OAuthException("Response body is incorrect. Can't extract token" . " and secret from this: '" . $response . "'", null);
     }
 }
Ejemplo n.º 2
0
 public function getAuthorizationUrl(OAuthConfig $config)
 {
     Preconditions::checkValidUrl($config->getCallback(), "Must provide a valid url as callback. Live does not support OOB");
     if ($config->hasScope()) {
         return sprintf(self::SCOPED_AUTHORIZE_URL, $config->getApiKey(), URLUtils::formURLEncode($config->getCallback()), URLUtils::formURLEncode($config->getScope()));
     } else {
         return sprintf(self::AUTHORIZE_URL, $config->getApiKey(), URLUtils::formURLEncode($config->getCallback()));
     }
 }
 public function getSignature($baseString, $apiSecret, $tokenSecret)
 {
     try {
         Preconditions::checkEmptyString($apiSecret, "Api secret cant be null or empty string");
         return URLUtils::percentEncode($apiSecret) . '&' . URLUtils::percentEncode($tokenSecret);
     } catch (\Exception $e) {
         throw new OAuthSignatureException($baseString, $e);
     }
 }
 private function getSortedAndEncodedParams(OAuthRequest $request)
 {
     $params = array();
     MapUtils::decodeAndAppendEntries($request->getQueryStringParams(), $params);
     MapUtils::decodeAndAppendEntries($request->getBodyParams(), $params);
     MapUtils::decodeAndAppendEntries($request->getOauthParameters(), $params);
     $params = MapUtils::sort($params);
     return URLUtils::percentEncode(MapUtils::concatSortedPercentEncodedParams($params));
 }
Ejemplo n.º 5
0
 public function extract($response)
 {
     Preconditions::checkEmptyString($response, "Response body is incorrect. " . "Can't extract a token from an empty string");
     if (preg_match(self::TOKEN_REGEX, $response, $matches)) {
         $token = URLUtils::formURLDecode($matches[1]);
         return new Token($token, self::EMPTY_SECRET, $response);
     } else {
         throw new OAuthException("Response body is incorrect. Can't extract a " . "token from this: '" . $response . "'", null);
     }
 }
Ejemplo n.º 6
0
 public function extract(OAuthRequest $request)
 {
     $this->checkPreconditions($request);
     $parameters = MapUtils::sort($request->getOauthParameters());
     $header = self::PREAMBLE;
     foreach ($parameters as $key => $value) {
         if (strlen($header) > strlen(self::PREAMBLE)) {
             $header .= self::PARAM_SEPARATOR;
         }
         $header .= sprintf("%s=\"%s\"", $key, URLUtils::percentEncode($value));
     }
     return $header;
 }
Ejemplo n.º 7
0
 public function getAuthorizationUrl(OAuthConfig $config)
 {
     Preconditions::checkValidUrl($config->getCallback(), "Must provide a valid url as callback. Foursquare2 does not support OOB");
     return sprintf(self::AUTHORIZATION_URL, $config->getApiKey(), URLUtils::formURLEncode($config->getCallback()));
 }
Ejemplo n.º 8
0
 public function getBodyContents()
 {
     return $this->payload != null ? $this->payload : URLUtils::formURLEncodeMap($this->bodyParams);
 }