Index: trunk/extensions/TwitterLogin/TwitterLogin.php |
— | — | @@ -31,6 +31,7 @@ |
32 | 32 | |
33 | 33 | $wgAutoloadClasses['SpecialTwitterLogin'] = dirname(__FILE__) . '/SpecialTwitterLogin.php'; |
34 | 34 | $wgAutoloadClasses['TwitterOAuth'] = dirname(__FILE__) . '/twitteroauth/twitteroauth.php'; |
| 35 | +$wgAutoloadClasses['MwTwitterOAuth'] = dirname(__FILE__) . '/TwitterLogin.twitteroauth.php'; |
35 | 36 | $wgAutoloadClasses['TwitterSigninUI'] = dirname(__FILE__) . '/TwitterLogin.body.php'; |
36 | 37 | |
37 | 38 | $wgExtensionMessagesFiles['TwitterLogin'] = dirname(__FILE__) .'/TwitterLogin.i18n.php'; |
Index: trunk/extensions/TwitterLogin/SpecialTwitterLogin.php |
— | — | @@ -107,7 +107,7 @@ |
108 | 108 | global $wgRequest, $wgOut, $wgUser; |
109 | 109 | |
110 | 110 | // Creating OAuth object |
111 | | - $connection = new TwitterOAuth( $this->_consumerKey, $this->_consumerSecret ); |
| 111 | + $connection = new MwTwitterOAuth( $this->_consumerKey, $this->_consumerSecret ); |
112 | 112 | |
113 | 113 | // set callback url |
114 | 114 | $oauthCallback = $this->getTitle( 'callback' )->getFullURL(); |
— | — | @@ -251,7 +251,7 @@ |
252 | 252 | |
253 | 253 | private function _doTwitterOAuth( $at, $ats ){ |
254 | 254 | /* Get user access tokens out of the session. */ |
255 | | - return new TwitterOAuth( |
| 255 | + return new MwTwitterOAuth( |
256 | 256 | $this->_consumerKey, |
257 | 257 | $this->_consumerSecret, |
258 | 258 | $at, |
Index: trunk/extensions/TwitterLogin/TwitterLogin.twitteroauth.php |
— | — | @@ -0,0 +1,57 @@ |
| 2 | +<?php |
| 3 | +/** |
| 4 | + * TwitterLogin.twitteroauth.php |
| 5 | + * Written by David Raison, based on the guideline published by Dave Challis |
| 6 | + * at http://blogs.ecs.soton.ac.uk/webteam/2010/04/13/254/ |
| 7 | + * @license: LGPL (GNU Lesser General Public License) http://www.gnu.org/licenses/lgpl.html |
| 8 | + * |
| 9 | + * @file TwitterLogin.twitteroauth.php |
| 10 | + * @ingroup TwitterLogin |
| 11 | + * |
| 12 | + * @author David Raison |
| 13 | + * |
| 14 | + * Extends the original TwitterOAuth class and overloads the http method |
| 15 | + * |
| 16 | + */ |
| 17 | + |
| 18 | + |
| 19 | +/** |
| 20 | + * Twitter OAuth class |
| 21 | + * |
| 22 | + */ |
| 23 | +class MwTwitterOAuth extends TwitterOAuth { |
| 24 | + |
| 25 | + private $_httpRequest; |
| 26 | + |
| 27 | + /** |
| 28 | + * Make an HTTP request |
| 29 | + * Overloads original twitteroauth http method |
| 30 | + * |
| 31 | + * @return API results |
| 32 | + */ |
| 33 | + public function http( $url, $method, $postfields = NULL ) { |
| 34 | + $this->http_info = array(); |
| 35 | + |
| 36 | + // the parent class sets the 'Expect:' http header but does not set a value.. we thus omit it here. |
| 37 | + $options = array( |
| 38 | + 'postData' => $postfields, |
| 39 | + 'sslVerifyHost' => $this->ssl_verifypeer, |
| 40 | + 'timeout' => $this->timeout |
| 41 | + ); |
| 42 | + |
| 43 | + //$response = Http::request( $method, $url ,$options ); // works, but doesn't allow us to query the response code |
| 44 | + $this->_httpRequest = MwHttpRequest::factory( $url, $options ); |
| 45 | + $this->_httpRequest->setUserAgent($this->useragent); |
| 46 | + |
| 47 | + $status = $this->_httpRequest->execute(); |
| 48 | + |
| 49 | + if ( $status->isGood() ) { |
| 50 | + $response = $this->_httpRequest->getContent(); |
| 51 | + $this->http_code = $this->_httpRequest->getStatus(); |
| 52 | + $this->http_header = $this->_httpRequest->getResponseHeaders(); |
| 53 | + |
| 54 | + $this->url = $this->_httpRequest->getFinalUrl(); |
| 55 | + return $response; |
| 56 | + } |
| 57 | + } |
| 58 | +} |
Property changes on: trunk/extensions/TwitterLogin/TwitterLogin.twitteroauth.php |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 59 | + native |