r100554 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r100553‎ | r100554 | r100555 >
Date:18:00, 23 October 2011
Author:kwisatz
Status:deferred
Tags:
Comment:
Follow up to r99355: now using mediawiki's MwHttpRequest class instead of curl
Modified paths:
  • /trunk/extensions/TwitterLogin/SpecialTwitterLogin.php (modified) (history)
  • /trunk/extensions/TwitterLogin/TwitterLogin.php (modified) (history)
  • /trunk/extensions/TwitterLogin/TwitterLogin.twitteroauth.php (added) (history)

Diff [purge]

Index: trunk/extensions/TwitterLogin/TwitterLogin.php
@@ -31,6 +31,7 @@
3232
3333 $wgAutoloadClasses['SpecialTwitterLogin'] = dirname(__FILE__) . '/SpecialTwitterLogin.php';
3434 $wgAutoloadClasses['TwitterOAuth'] = dirname(__FILE__) . '/twitteroauth/twitteroauth.php';
 35+$wgAutoloadClasses['MwTwitterOAuth'] = dirname(__FILE__) . '/TwitterLogin.twitteroauth.php';
3536 $wgAutoloadClasses['TwitterSigninUI'] = dirname(__FILE__) . '/TwitterLogin.body.php';
3637
3738 $wgExtensionMessagesFiles['TwitterLogin'] = dirname(__FILE__) .'/TwitterLogin.i18n.php';
Index: trunk/extensions/TwitterLogin/SpecialTwitterLogin.php
@@ -107,7 +107,7 @@
108108 global $wgRequest, $wgOut, $wgUser;
109109
110110 // Creating OAuth object
111 - $connection = new TwitterOAuth( $this->_consumerKey, $this->_consumerSecret );
 111+ $connection = new MwTwitterOAuth( $this->_consumerKey, $this->_consumerSecret );
112112
113113 // set callback url
114114 $oauthCallback = $this->getTitle( 'callback' )->getFullURL();
@@ -251,7 +251,7 @@
252252
253253 private function _doTwitterOAuth( $at, $ats ){
254254 /* Get user access tokens out of the session. */
255 - return new TwitterOAuth(
 255+ return new MwTwitterOAuth(
256256 $this->_consumerKey,
257257 $this->_consumerSecret,
258258 $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
159 + native

Follow-up revisions

RevisionCommit summaryAuthorDate
r100555changed extension version to reflect changes done in r100554kwisatz18:07, 23 October 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r99355initial import of TwitterLogin extensionkwisatz16:01, 9 October 2011

Status & tagging log