3 require_once(dirname(dirname(__FILE__)) .
'/libextinc/OAuth.php');
18 $this->consumer =
new OAuthConsumer(
$key, $secret, null);
23 public static function dummy() {}
27 foreach ($hrh as
$h) {
28 if (preg_match(
'|OAuth-Error:\s([^;]*)|i', $h, $matches)) {
37 foreach ($hrh as
$h) {
38 if (preg_match(
'|Content-Type:\s([^;]*)|i', $h, $matches)) {
59 $statuscode =
'unknown';
60 if (preg_match(
'/^HTTP.*\s([0-9]{3})/', $http_response_header[0], $matches)) {
61 $statuscode = $matches[1];
64 $error =
$context .
' [statuscode: ' . $statuscode .
']: ';
65 $oautherror = self::getOAuthError($http_response_header);
67 if (!empty($oautherror)) {
68 $error .= $oautherror;
80 $req_req->sign_request($this->signer, $this->consumer, null);
82 $response_req = self::getHTTP(
84 'Contacting request_token endpoint on the OAuth Provider' 87 parse_str($response_req, $responseParsed);
89 if (array_key_exists(
'error', $responseParsed)) {
90 throw new Exception(
'Error getting request token: ' . $responseParsed[
'error']);
93 $requestToken = $responseParsed[
'oauth_token'];
94 $requestTokenSecret = $responseParsed[
'oauth_token_secret'];
96 return new OAuthToken($requestToken, $requestTokenSecret);
101 $params = array(
'oauth_token' => $requestToken->key);
103 $params[
'oauth_callback'] = $callback;
105 $authorizeURL = \SimpleSAML\Utils\HTTP::addURLParameters(
$url,
$params);
110 return $authorizeURL;
116 $acc_req->sign_request($this->signer, $this->consumer, $requestToken);
121 throw new Exception(
'Error contacting request_token endpoint on the OAuth Provider');
126 parse_str($response_acc, $accessResponseParsed);
128 if (array_key_exists(
'error', $accessResponseParsed)) {
129 throw new Exception(
'Error getting request token: ' . $accessResponseParsed[
'error']);
132 $accessToken = $accessResponseParsed[
'oauth_token'];
133 $accessTokenSecret = $accessResponseParsed[
'oauth_token_secret'];
135 return new OAuthToken($accessToken, $accessTokenSecret);
141 $data_req->sign_request($this->signer, $this->consumer, $accessToken);
142 $postdata = $data_req->to_postdata();
146 'verify_peer' =>
false,
147 'capture_peer_cert' =>
true,
148 'capture_peer_chain' =>
true 152 'content' => $postdata,
153 'header' =>
'Content-Type: application/x-www-form-urlencoded',
168 $data_req->sign_request($this->signer, $this->consumer, $accessToken);
172 return json_decode(
$data,
true);
__construct($key, $secret)
OAuth PECL extension includes an OAuth Exception class, so we need to wrap the definition of this cla...
getRequestToken($url, $parameters=null)
static redirectTrustedURL($url, $parameters=array())
This function redirects to the specified URL without performing any security checks.
static getContentType($hrh)
static getOAuthError($hrh)
getAuthorizeRequest($url, $requestToken, $redirect=true, $callback=null)
static getHTTP($url, $context='')
static fetch($url, $context=array(), $getHeaders=false)
Helper function to retrieve a file or URL with proxy support, also supporting proxy basic authorizati...
static from_consumer_and_token($consumer, $token, $http_method, $http_url, $parameters=null)
pretty much a helper function to set up the request
getUserInfo($url, $accessToken, $opts=null)
getAccessToken($url, $requestToken, $parameters=null)
The HMAC-SHA1 signature method uses the HMAC-SHA1 signature algorithm as defined in [RFC2104] where t...
postRequest($url, $accessToken, $parameters)