Add support for extended tweets V06.006
authorymh <ymh.work@gmail.com>
Sun, 23 Sep 2018 14:12:38 +0200
changeset 1474 53f0f4ed20c8
parent 1473 9939b42f1eb4
child 1475 a8f1006005c7
Add support for extended tweets
web/marathon-serpentine-2018/reloader.php
web/res/js/live-polemic.js
web/search_tweets.php
--- a/web/marathon-serpentine-2018/reloader.php	Sat Sep 22 15:25:25 2018 +0200
+++ b/web/marathon-serpentine-2018/reloader.php	Sun Sep 23 14:12:38 2018 +0200
@@ -2,13 +2,13 @@
 include_once('./config.php');
 header("Content-type: application/x-javascript");
 ?>
-var startEmbedCode = "<?php echo($islive_embed ? $islive_embed : '') ?>";
+var startEmbedCode = '<?php echo(addslashes($islive_embed ? $islive_embed : '')) ?>';
 
 function getCurrentEmbedCode() {
     var resCode = null;
     var embedCodeList = [
     <?php foreach ($embed_code_list as $time_entry): ?>
-        [<?php echo($time_entry[0]->getTimestamp() * 1000); ?>, <?php echo($time_entry[1]->getTimestamp() * 1000); ?>, "<?php echo($time_entry[2]);?>"],
+        [<?php echo($time_entry[0]->getTimestamp() * 1000); ?>, <?php echo($time_entry[1]->getTimestamp() * 1000); ?>, '<?php echo(addslashes($time_entry[2]));?>'],
     <?php endforeach; ?>
     ];
     var currentTime = Date.now();
--- a/web/res/js/live-polemic.js	Sat Sep 22 15:25:25 2018 +0200
+++ b/web/res/js/live-polemic.js	Sun Sep 23 14:12:38 2018 +0200
@@ -249,7 +249,8 @@
     for (var j in annotations) {
         if (j != "default") {
             for (var k in annotations[j].keywords) {
-                if (tweet.text.search(annotations[j].keywords[k]) != -1) {
+                var tweetText = tweet.full_text;
+                if (tweetText.search(annotations[j].keywords[k]) != -1) {
                     ann.push(j);
                     break;
                 }
@@ -268,7 +269,7 @@
     }
     
     
-    var tab = tweet.text.replace(twCx.urlRegExp,'').match(twCx.wordRegExp);
+    var tab = tweet.full_text.replace(twCx.urlRegExp,'').match(twCx.wordRegExp);
     _(tab).each(function(w) {
         var word = w.toLowerCase();
         if (_(twCx.stopWords).indexOf(word) == -1 && _(tracking_keywords).indexOf(word) == -1 && word[0] != '@') {
@@ -294,7 +295,7 @@
     });
     
     _(twCx.suggestCount).each(function(_k) {
-        if (tweet.text.search(_k.rgxp) != -1) {
+        if (tweet.full_text.search(_k.rgxp) != -1) {
             _k.freq++;
             _(ann).each(function(_a) {
                 _k.annotations[_a] = 1 + ( _k.annotations[_a] || 0 )
@@ -458,7 +459,7 @@
     	+ '" data-title="Tweet by '
     	+ _(tweet.user.name).escape()
     	+ '" data-description="'
-    	+ _(tweet.text).escape()
+    	+ _(tweet.full_text).escape()
     	+ '" data-uri="http://twitter.com/'
     	+ tweet.user.screen_name
     	+ '/status/'
@@ -491,10 +492,10 @@
         var txt = '';
         tweet.html_parts.sort(function(a, b) { return a.start - b.start });
         _(tweet.html_parts).each(function(_e) {
-            txt += highlight( tweet.text.substring(lastend, _e.start) ) + _e.link + highlight( _e.text ) + '</a>';
+            txt += highlight( tweet.full_text.substring(lastend, _e.start) ) + _e.link + highlight( _e.text ) + '</a>';
             lastend = _e.end;
         });
-        txt += highlight( tweet.text.substring(lastend) );
+        txt += highlight( tweet.full_text.substring(lastend) );
         html += '<p class="tweet_text"><b>' + a_user + highlight('@' + tweet.user.screen_name) + '</a>' + ( className == 'full' ? ' (' + tweet.user.name + ')</b><br />' : '</b> : ') + txt + '</p>';
         if (className == 'full' && el == 'li') {
             html += '<div class="tweet_actions"><a href="http://twitter.com/' + tweet.user.screen_name + '/status/' + tweet.id + '" onclick="tweetPopup(this.href); return false;" target="_blank">afficher tweet</a> - ';
@@ -696,7 +697,7 @@
     if (twCx.filtre) {
         var tweets = _(twCx.tweets).filter(function(tweet) {
             var mention = '@' + tweet.user.screen_name;
-            return ( tweet.text.search(twCx.filtre) != -1 ) || ( mention.search(twCx.filtre) != -1 );
+            return ( tweet.full_text.search(twCx.filtre) != -1 ) || ( mention.search(twCx.filtre) != -1 );
         });
         $("#inp_q").val(twCx.filtreTexte + ' (' + tweets.length + ' tweets)');
         if (tweets.length) {
--- a/web/search_tweets.php	Sat Sep 22 15:25:25 2018 +0200
+++ b/web/search_tweets.php	Sun Sep 23 14:12:38 2018 +0200
@@ -31,7 +31,11 @@
     $token = unserialize($_SESSION['TWITTER_ACCESS_TOKEN']);
     $connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $token['oauth_token'], $token['oauth_token_secret']);
 
-    $statuses = $connection->get("search/tweets", $_GET);
+    $parameters = array_merge([
+        'tweet_mode' => 'extended'
+    ], $_GET ? $_GET : []);
+
+    $statuses = $connection->get("search/tweets", $parameters);
     // $client = $token->getHttpClient($configuration);
     // $client->setUri("https://api.twitter.com/1.1/$endpoint.json");
     // $client->setMethod(Zend_Http_Client::GET);