/var
/www
/fastuser-phone
/data
/www
/phone-906.ru
/vendor
/lusitanian
/oauth
/src
/OAuth
/Common
/Http
/Client
/StreamClient.php
if (is_array($requestBody)) {
$requestBody = http_build_query($requestBody, '', '&');
}
$extraHeaders['Content-length'] = 'Content-length: '.strlen($requestBody);
$context = $this->generateStreamContext($requestBody, $extraHeaders, $method);
$level = error_reporting(0);
$response = file_get_contents($endpoint->getAbsoluteUri(), false, $context);
error_reporting($level);
if (false === $response) {
$lastError = error_get_last();
if (is_null($lastError)) {
throw new TokenResponseException(
'Failed to request resource. HTTP Code: ' .
((isset($http_response_header[0]))?$http_response_header[0]:'No response')
);
}
throw new TokenResponseException($lastError['message']);
}
return $response;
}
private function generateStreamContext($body, $headers, $method)
{
return stream_context_create(
array(
'http' => array(
'method' => $method,
'header' => implode("\r\n", array_values($headers)),
'content' => $body,
'protocol_version' => '1.1',
'user_agent' => $this->userAgent,
'max_redirects' => $this->maxRedirects,
'timeout' => $this->timeout
),
)
);
/var
/www
/fastuser-phone
/data
/www
/phone-906.ru
/vendor
/lusitanian
/oauth
/src
/OAuth
/OAuth1
/Service
/AbstractService.php
SignatureInterface $signature,
UriInterface $baseApiUri = null
) {
parent::__construct($credentials, $httpClient, $storage);
$this->signature = $signature;
$this->baseApiUri = $baseApiUri;
$this->signature->setHashingAlgorithm($this->getSignatureMethod());
}
/**
* {@inheritDoc}
*/
public function requestRequestToken()
{
$authorizationHeader = array('Authorization' => $this->buildAuthorizationHeaderForTokenRequest());
$headers = array_merge($authorizationHeader, $this->getExtraOAuthHeaders());
$responseBody = $this->httpClient->retrieveResponse($this->getRequestTokenEndpoint(), array(), $headers);
$token = $this->parseRequestTokenResponse($responseBody);
$this->storage->storeAccessToken($this->service(), $token);
return $token;
}
/**
* {@inheritdoc}
*/
public function getAuthorizationUri(array $additionalParameters = array())
{
// Build the url
$url = clone $this->getAuthorizationEndpoint();
foreach ($additionalParameters as $key => $val) {
$url->addToQuery($key, $val);
}
return $url;
}
/var
/www
/fastuser-phone
/data
/www
/phone-906.ru
/oauth.php
$credentials = new OAuth\Common\Consumer\Credentials(
Config::get("services.{$provider}.id"),
Config::get("services.{$provider}.secret"),
App::url("oauth.php?provider={$provider}")
);
$scope = isset($scopes[$provider]) ? $scopes[$provider] : array();
$storage = new OAuth\Common\Storage\Session;
$factory = new OAuth\ServiceFactory;
// Use cURL
// $factory->setHttpClient(new OAuth\Common\Http\Client\CurlClient);
$service = $factory->createService($provider, $credentials, $storage, $scope);
if ($provider === 'twitter') {
if (empty($_GET['oauth_token'])) {
$oauth_token = $service->requestRequestToken()->getRequestToken();
$authUrl = $service->getAuthorizationUri(compact('oauth_token'));
} else {
try {
$token = $storage->retrieveAccessToken(ucfirst($provider));
$service->requestAccessToken(
@$_GET['oauth_token'],
@$_GET['oauth_verifier'],
$token->getRequestTokenSecret()
);
} catch(Exception $e) {
exit('Oauth Retrieve Access Token Error.');
}
}
} else {
if (empty($_GET['code'])) {
$authUrl = $service->getAuthorizationUri();
} else {
try {
$state = isset($_GET['state']) ? $_GET['state'] : null;
$service->requestAccessToken($_GET['code'], $state);