not handling HTML responses #5

Closed
srigi opened this Issue Mar 2, 2011 · 2 comments

Projects

None yet

2 participants

@srigi
srigi commented Mar 2, 2011

When using Twitter class for OAuth authentication, some responses are in text/html MIME type. Library is not handling this case:

$twitter = new Twitter($consumerKey, $consumerSecret);
$requestToken = $twitter->request($requestTokenUrl);

PATCH:

diff --git a/twitter.class.php b/twitter.class.php
index 84a50fe..5f84faf 100644
--- a/twitter.class.php
+++ b/twitter.class.php
@@ -228,6 +228,17 @@ class Twitter

            } elseif (strpos($type, 'json')) {
                    $payload = @json_decode($result); // intentionally @
  •           } elseif (strpos($type, 'html')) {
    
  •                   $payload = explode('&', $result);
    
  •                   $temp = array();
    
  •                   foreach ($payload as $keyValue) {
    
  •                           list($key, $value) = explode('=', $keyValue);
    
  •                           $temp[$key] = $value;
    
  •                   }
    
  •                   $payload = $temp;
            }
    
@srigi
srigi commented Mar 2, 2011

pastebin patch (sry): http://pastebin.com/U34RujcK

@dg dg closed this Mar 6, 2013
@dg
Owner
dg commented Mar 6, 2013

Now is everything JSON.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment