From ba5cbafd1fd41ed7760d481971ecd0c8d1424fa0 Mon Sep 17 00:00:00 2001
From: Olav Morken <olav.morken@uninett.no>
Date: Mon, 14 Mar 2011 14:01:32 +0000
Subject: [PATCH] authtwitter: Change API endpoint to use
 https://api.twitter.com/ .

This is specified at: http://dev.twitter.com/pages/auth#at-twitter

Thanks to Andjelko Horvat for fixing this.

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@2774 44740490-163a-0410-bde0-09ae8108e29a
---
 modules/authtwitter/lib/Auth/Source/Twitter.php | 17 ++++-------------
 1 file changed, 4 insertions(+), 13 deletions(-)

diff --git a/modules/authtwitter/lib/Auth/Source/Twitter.php b/modules/authtwitter/lib/Auth/Source/Twitter.php
index 1fba2eb50..9f4c0fd50 100644
--- a/modules/authtwitter/lib/Auth/Source/Twitter.php
+++ b/modules/authtwitter/lib/Auth/Source/Twitter.php
@@ -71,7 +71,7 @@ class sspmod_authtwitter_Auth_Source_Twitter extends SimpleSAML_Auth_Source {
 		$consumer = new sspmod_oauth_Consumer($this->key, $this->secret);
 
 		// Get the request token
-		$requestToken = $consumer->getRequestToken('http://twitter.com/oauth/request_token');
+		$requestToken = $consumer->getRequestToken('https://api.twitter.com/oauth/request_token');
 		SimpleSAML_Logger::debug("Got a request token from the OAuth service provider [" . 
 			$requestToken->key . "] with the secret [" . $requestToken->secret . "]");
 
@@ -83,17 +83,12 @@ class sspmod_authtwitter_Auth_Source_Twitter extends SimpleSAML_Auth_Source {
 		$session->setData('oauth', 'oauth', $oauthState);
 
 		// Authorize the request token
-		$consumer->getAuthorizeRequest('http://twitter.com/oauth/authenticate', $requestToken);
+		$consumer->getAuthorizeRequest('https://api.twitter.com/oauth/authenticate', $requestToken);
 
 	}
 	
 	
-	
 	public function finalStep(&$state) {
-		
-		
-		
-		
 		$requestToken = unserialize($state['requestToken']);
 		
 		#echo '<pre>'; print_r($requestToken); exit;
@@ -104,19 +99,16 @@ class sspmod_authtwitter_Auth_Source_Twitter extends SimpleSAML_Auth_Source {
 			$requestToken->key . "] with the secret [" . $requestToken->secret . "]");
 
 		// Replace the request token with an access token
-		$accessToken = $consumer->getAccessToken('http://twitter.com/oauth/access_token', $requestToken);
+		$accessToken = $consumer->getAccessToken('https://api.twitter.com/oauth/access_token', $requestToken);
 		SimpleSAML_Logger::debug("Got an access token from the OAuth service provider [" . 
 			$accessToken->key . "] with the secret [" . $accessToken->secret . "]");
 			
-
-		
-		$userdata = $consumer->getUserInfo('http://twitter.com/account/verify_credentials.json', $accessToken);
+		$userdata = $consumer->getUserInfo('https://api.twitter.com/account/verify_credentials.json', $accessToken);
 		
 		$attributes = array();
 		foreach($userdata AS $key => $value) {
 			if (is_string($value))
 				$attributes['twitter.' . $key] = array((string)$value);
-			
 		}
 		
 		if (array_key_exists('screen_name', $userdata) ) {
@@ -126,7 +118,6 @@ class sspmod_authtwitter_Auth_Source_Twitter extends SimpleSAML_Auth_Source {
 		if (array_key_exists('id_str', $userdata) )
 			$attributes['twitter_targetedID'] = array('http://twitter.com!' . $userdata['id_str']);
 			
-		
 		$state['Attributes'] = $attributes;
 	}
 
-- 
GitLab