X-Git-Url: https://git.ao2.it/tweeper.git/blobdiff_plain/50e34cbbe2a9a8d993f0bba6206b01fcc0e1bad3..84bcd8d286d302fc065a18c2b751f49dc4ea8791:/src/Tweeper.php

diff --git a/src/Tweeper.php b/src/Tweeper.php
index b794368..f1d579f 100644
--- a/src/Tweeper.php
+++ b/src/Tweeper.php
@@ -36,7 +36,7 @@ date_default_timezone_set('UTC');
  */
 class Tweeper {
 
-  private static $userAgent = "Mozilla/5.0 (Linux; U; Android 4.3; en-us; SM-N900T Build/JSS15J)";
+  private static $userAgent = "Mozilla/5.0";
   private static $maxConnectionTimeout = 5;
   private static $maxConnectionRetries = 5;
 
@@ -455,7 +455,15 @@ class Tweeper {
       return NULL;
     }
 
-    $html = Tweeper::getUrlContents($src_url);
+    // Override User-Agent for twitter.com to force it to serve the mobile UI.
+    if ($host == "twitter.com") {
+      $user_agent = "Mozilla/5.0 (Linux; U; Android 4.3; en-us; SM-N900T Build/JSS15J)";
+    }
+    else {
+      $user_agent = NULL;
+    }
+
+    $html = Tweeper::getUrlContents($src_url, $user_agent);
     if (FALSE === $html) {
       trigger_error("Failed to retrieve $src_url", E_USER_WARNING);
       return NULL;