From 75ed25c61c1a865ea179ee789984ff1cda9384e1 Mon Sep 17 00:00:00 2001
From: Olav Morken <olav.morken@uninett.no>
Date: Tue, 8 Feb 2011 13:50:51 +0000
Subject: [PATCH] oauth: Add support for request parameters.

Thanks to Brook Schofield for implementing this.

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@2734 44740490-163a-0410-bde0-09ae8108e29a
---
 modules/oauth/lib/Consumer.php | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/modules/oauth/lib/Consumer.php b/modules/oauth/lib/Consumer.php
index e76efdfa7..33c33fd6a 100644
--- a/modules/oauth/lib/Consumer.php
+++ b/modules/oauth/lib/Consumer.php
@@ -69,8 +69,8 @@ class sspmod_oauth_Consumer {
 		return $response;
 	}
 	
-	public function getRequestToken($url) {
-		$req_req = OAuthRequest::from_consumer_and_token($this->consumer, NULL, "GET", $url, NULL);
+	public function getRequestToken($url, $parameters = NULL) {
+		$req_req = OAuthRequest::from_consumer_and_token($this->consumer, NULL, "GET", $url, $parameters);
 		$req_req->sign_request($this->signer, $this->consumer, NULL);
 
 		$response_req = self::getHTTP($req_req->to_url(), 
@@ -99,9 +99,9 @@ class sspmod_oauth_Consumer {
 		return $authorizeURL;
 	}
 	
-	public function getAccessToken($url, $requestToken) {
+	public function getAccessToken($url, $requestToken, $parameters = NULL) {
 
-		$acc_req = OAuthRequest::from_consumer_and_token($this->consumer, $requestToken, "GET", $url, NULL);
+		$acc_req = OAuthRequest::from_consumer_and_token($this->consumer, $requestToken, "GET", $url, $parameters);
 		$acc_req->sign_request($this->signer, $this->consumer, $requestToken);
 		
 		$response_acc = file_get_contents($acc_req->to_url());
@@ -149,12 +149,15 @@ class sspmod_oauth_Consumer {
 		return $response;
 	}
 	
-	public function getUserInfo($url, $accessToken) {
+	public function getUserInfo($url, $accessToken, $opts = NULL) {
 		
 		$data_req = OAuthRequest::from_consumer_and_token($this->consumer, $accessToken, "GET", $url, NULL);
 		$data_req->sign_request($this->signer, $this->consumer, $accessToken);
 
-		$data = file_get_contents($data_req->to_url());
+		if (is_array($opts)) {
+			$opts = stream_context_create($opts);
+		}
+		$data = file_get_contents($data_req->to_url(), FALSE, $opts);
 		#print_r($data);
 
 		$dataDecoded = json_decode($data, TRUE);
-- 
GitLab