/** * (non-PHPdoc) * @see \Socialite\Component\OAuth\SignatureMethod\OAuthSignatureMethod::build() */ public function build(OAuthRequest $request, OAuthConsumer $consumer, OAuthToken $token = null) { $parts = array(OAuth::urlencode($consumer->getSecret())); $parts[] = $token instanceof OAuthToken ? OAuth::urlencode($token->getSecret()) : ''; $base = $request->getBaseSignature(); $key = join('&', $parts); if (function_exists('hash_hmac')) { $hmac = hash_hmac('sha1', $base, $key, true); } else { $blocksize = 64; $hashfunc = 'sha1'; if (strlen($key) > $blocksize) { $key = pack('H*', $hashfunc($key)); } $key = str_pad($key, $blocksize, chr(0x0)); $ipad = str_repeat(chr(0x36), $blocksize); $opad = str_repeat(chr(0x5c), $blocksize); $hmac = pack('H*', $hashfunc(($key ^ $opad) . pack('H*', $hashfunc(($key ^ $ipad) . $base_string)))); } return base64_encode($hmac); }
public function testStaticMethods() { $this->assertEquals($this->encoded, OAuth::urlencode($this->raw)); $this->assertEquals($this->raw, OAuth::urldecode($this->encoded)); $this->assertEquals($this->raw, OAuth::buildHttpQuery($this->array)); }
/** * Returns the normalized URL. * * @param string $url * @return string */ public function getNormalizedUrl($url) { $parameters = array('{REDIRECT_URI}' => $this->callback, '{CLIENT_ID}' => $this->consumer->getKey(), '{SCOPE}' => implode($this->oauth_scope_separator, $this->getScope()), '{STATE}' => md5(microtime(true))); foreach ($parameters as $name => $value) { $url = str_replace($name, OAuth::urlencode($value), $url); } return $url; }
/** * (non-PHPdoc) * @see \Socialite\Component\OAuth\SignatureMethod\OAuthSignatureMethod::build() */ public function build(OAuthRequest $request, OAuthConsumer $consumer, OAuthToken $token = null) { $parts = array(OAuth::urlencode($consumer->getSecret())); $parts[] = $token instanceof OAuthToken ? OAuth::urlencode($token->getSecret()) : ''; return join('&', $parts); }