Advertisement:

Author Topic: Auto Tweet Embed  (Read 35151 times)

Offline vbgamer45

  • Customizer
  • SMF Super Hero
  • *
  • Posts: 22,738
    • smfhacks on Facebook
    • VBGAMER45 on GitHub
    • @createaforum on Twitter
    • SMF For Free
Re: Auto Tweet Embed
« Reply #180 on: May 13, 2020, 11:57:57 AM »
Glad to help. Probably was a cache issue. Had to wait for it to timeout.
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

Offline laboo9

  • Newbie
  • *
  • Posts: 4
Re: Auto Tweet Embed
« Reply #181 on: May 28, 2020, 07:11:06 PM »
I installed the auto tweet embed a couple days ago.  Everything was working until this morning when the tweets stopped embedding as they look on twitter.  Now they have the text of the tweet along with hashtags, links to video, and link to pics with the actual link to the actual tweet underneath. 

I'm using 2.0.17.  I have tried uninstalling and reinstalling without any issues but the tweets still don't embed correctly.  Any ideas?

Offline vbgamer45

  • Customizer
  • SMF Super Hero
  • *
  • Posts: 22,738
    • smfhacks on Facebook
    • VBGAMER45 on GitHub
    • @createaforum on Twitter
    • SMF For Free
Re: Auto Tweet Embed
« Reply #182 on: May 28, 2020, 07:16:16 PM »
Check your forums error log.
And your tweet-cache.php file permissions.
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

Offline laboo9

  • Newbie
  • *
  • Posts: 4
Re: Auto Tweet Embed
« Reply #183 on: May 28, 2020, 08:17:06 PM »
the only error I'm getting is File:....../forums/Themes/default/languages/OharaYTEmbed.english.php (main sub template - eval?)

tweet-cache.php file permissions is 0666

Offline vbgamer45

  • Customizer
  • SMF Super Hero
  • *
  • Posts: 22,738
    • smfhacks on Facebook
    • VBGAMER45 on GitHub
    • @createaforum on Twitter
    • SMF For Free
Re: Auto Tweet Embed
« Reply #184 on: May 28, 2020, 08:23:42 PM »
Do you have a link to the post?
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

Offline laboo9

  • Newbie
  • *
  • Posts: 4
Re: Auto Tweet Embed
« Reply #185 on: May 28, 2020, 08:35:02 PM »
It's a private board.

hxxp:www.hard2bhumble.net/forums/index.php?topic=13791.msg227105#msg227105 [nonactive]

Offline vbgamer45

  • Customizer
  • SMF Super Hero
  • *
  • Posts: 22,738
    • smfhacks on Facebook
    • VBGAMER45 on GitHub
    • @createaforum on Twitter
    • SMF For Free
Re: Auto Tweet Embed
« Reply #186 on: May 28, 2020, 08:51:13 PM »
Ah, that will be hard for me to check. Basically I would look in the console log to see if there are any javascript errors and also checking the response from tweet-cache in the network log.
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

Offline laboo9

  • Newbie
  • *
  • Posts: 4
Re: Auto Tweet Embed
« Reply #187 on: May 28, 2020, 09:57:54 PM »
I'm pretty new to this stuff but is this what you are looking for?

<?php
/*
Rough take on Twitter oEmbed for VeloRooms
by L'arri : voici.l.arriviste@gmail.com
27 October 2014

Packaged and modified by SMFHacks.com -vbgamer45
*/

// I used SMF items where possible for database interactions and required includes.
global $ssi_guest_access;
$ssi_guest_access = 1;
require(dirname(__FILE__) . '/SSI.php');

global $smcFunc;

$_GET = filter_input_array(INPUT_GET, FILTER_SANITIZE_NUMBER_INT);
$qv  = $_GET['id'];
if (!empty($qv))
{
   check_cache($qv);
}
else
{
   echo '{"html":"<p style=\"color: #666; border: 1px dotted #666; padding: 5px; width: 490px;\">' . $txt['autotwitter_blankid'] . '</p>"}';
}

function check_cache($tweet)
{
   global  $smcFunc;
   
   if (!is_numeric($tweet))
      return;
   
   $request = $smcFunc['db_query']('','SELECT
      html from
   {db_prefix}tweet_cache
   where tweetid = {raw:tweet}',
   array(
      'tweet' => $tweet
      )
   );
   
   if ($smcFunc['db_num_rows']($request) == 0)
   {
      add_cache($tweet);
   }
   else
   {
      while ($row = $smcFunc['db_fetch_row']($request))
         echo '{"html" : "' . $row[0] .'"}';
   }      
   $smcFunc['db_free_result']($request);
   
}

function add_cache($tweet)
{
   global $smcFunc, $txt, $sourcedir;

   $twitterapi_url = "hxxp:api.twitter.com/1.1/statuses/oembed.json?id= [nonactive]";
   $twitterapi_url = $twitterapi_url . $tweet;
   
   if (function_exists('curl_init'))
    {
        $curl = curl_init($twitterapi_url);
       curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
       curl_setopt($curl,CURLOPT_SSL_VERIFYPEER, FALSE);
       $response = curl_exec($curl);
       curl_close($curl);
    }
    else
    {
        require_once($sourcedir . '/Subs-Package.php');
        $response = fetch_web_data($twitterapi_url);
    }
   
   
   $json_content = json_decode($response, true);
   $json_content = preg_replace( "/\r|\n/", "", $json_content );
   
   $html = $json_content['html'];
   if (!empty($html))
   {

      $smcFunc['db_query']('', '
         SET NAMES {string:db_character_set}',
         array(
            'db_character_set' => 'utf8mb4',
         )
      );

      $request = $smcFunc['db_insert']('',
            '{db_prefix}tweet_cache',
            array(
               'tweetid' => 'raw', 'html' => 'text'
            ),
            array(
               $tweet, addslashes($html)
          ),
            array('tweetid','html')
         );
      echo '{"html" : "' . addslashes($html) .'"}';
   }
   else
   {
      echo '{"html":"<p style=\"color: #666; border: 1px dotted #666; padding: 5px; width: 490px;\">' . $txt['autotwitter_tweeterror'] . '</p>"}';
   }
   
}

?>

Offline vbgamer45

  • Customizer
  • SMF Super Hero
  • *
  • Posts: 22,738
    • smfhacks on Facebook
    • VBGAMER45 on GitHub
    • @createaforum on Twitter
    • SMF For Free
Re: Auto Tweet Embed
« Reply #188 on: May 28, 2020, 10:57:08 PM »
No looking for javascript errors...
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

Offline pocttopus

  • Full Member
  • ***
  • Posts: 470
  • Low pressure
    • @pocttopus on Twitter
    • mkreef.com
Re: Auto Tweet Embed
« Reply #189 on: May 29, 2020, 02:59:34 AM »
Disable the Enhanced Tracking protection to your site from your browser.


Offline kilk

  • Semi-Newbie
  • *
  • Posts: 25
    • Elddem The MMORPG
Re: Auto Tweet Embed
« Reply #190 on: June 09, 2020, 04:07:27 PM »
I havent had any issues with this mod, just solid af, thank you again vbgamer
Elddem The MMORPG - https://www.elddem.com | Denarius (D) Cryptocurrrency - https://www.denarius.io | BlockForums - Cryptocurrency Community Forums - https://www.blockforums.org

Offline natcip

  • Jr. Member
  • **
  • Posts: 106
Re: Auto Tweet Embed
« Reply #191 on: August 02, 2020, 10:38:44 AM »
For whatever reason some tweets won't embed at all, like in this post, even though the link structure is identical to other posts where it did embed. :-\

Offline vbgamer45

  • Customizer
  • SMF Super Hero
  • *
  • Posts: 22,738
    • smfhacks on Facebook
    • VBGAMER45 on GitHub
    • @createaforum on Twitter
    • SMF For Free
Re: Auto Tweet Embed
« Reply #192 on: August 02, 2020, 10:57:21 AM »
Looks like i get a database error are you using latest version?
http://www.brandysource.net/tweet-cache.php?id=1289643269563904002
If so post the db error from your logs
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

Offline natcip

  • Jr. Member
  • **
  • Posts: 106
Re: Auto Tweet Embed
« Reply #193 on: August 02, 2020, 01:36:02 PM »
Yes, I've just updated it in May.
And there are no error log entries.

Offline vbgamer45

  • Customizer
  • SMF Super Hero
  • *
  • Posts: 22,738
    • smfhacks on Facebook
    • VBGAMER45 on GitHub
    • @createaforum on Twitter
    • SMF For Free
Re: Auto Tweet Embed
« Reply #194 on: August 02, 2020, 02:08:03 PM »
What happens when you click that link above as admin?
I want to see the message returned.
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

Offline natcip

  • Jr. Member
  • **
  • Posts: 106
Re: Auto Tweet Embed
« Reply #195 on: August 03, 2020, 06:21:07 AM »
Code: [Select]
Incorrect string value: '\xF0\x9F\x92\x80 <...' for column `brandyso_sql1`.`brandy4f_sql1_smf_tweet_cache`.`html` at row 1
File: /home/www/brandyso/tweet-cache.php
Line: 93

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 72,806
    • StoryBB/StoryBB on GitHub
Re: Auto Tweet Embed
« Reply #196 on: August 03, 2020, 06:22:59 AM »
Can't store emoji... if the mod pushed it through $smcFunc['htmlspecialchars'] this would be fine.
Please don’t PM me for paid work, I’m not for hire, and even if I was, I doubt you could afford me.
USD$150 per hour. Typical waiting list 3 months.

Offline vbgamer45

  • Customizer
  • SMF Super Hero
  • *
  • Posts: 22,738
    • smfhacks on Facebook
    • VBGAMER45 on GitHub
    • @createaforum on Twitter
    • SMF For Free
Re: Auto Tweet Embed
« Reply #197 on: August 03, 2020, 06:55:29 AM »
Would that break the html response? Thinking I could do that but then do  un_htmlspecialchars to get right content?

Code: [Select]
$html = $json_content['html'];
if (!empty($html))
{

$smcFunc['db_query']('', '
SET NAMES {string:db_character_set}',
array(
'db_character_set' => 'utf8mb4',
)
);

$request = $smcFunc['db_insert']('',
'{db_prefix}tweet_cache',
array(
'tweetid' => 'raw', 'html' => 'text'
),
array(
$tweet, addslashes($html)
),
array('tweetid','html')
);
echo '{"html" : "' . addslashes($html) .'"}';
}
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 72,806
    • StoryBB/StoryBB on GitHub
Re: Auto Tweet Embed
« Reply #198 on: August 03, 2020, 07:00:43 AM »
You only need to htmlspecialchars it before sending to the database (because even though you have a SET NAMES call, none of that matters if the underlying table isn't also utf8mb4 - which by evidence of the above, it is not) and I *think* you can safely un_htmlspecialchars on the way back.

Alternatively, borrow the routine from $smcFunc that fixes UTF-8 (it entity encodes all emoji as numeric-form entities) and just html_entity_decode on the way back?

Though entities are valid HTML so...
Please don’t PM me for paid work, I’m not for hire, and even if I was, I doubt you could afford me.
USD$150 per hour. Typical waiting list 3 months.

Offline vbgamer45

  • Customizer
  • SMF Super Hero
  • *
  • Posts: 22,738
    • smfhacks on Facebook
    • VBGAMER45 on GitHub
    • @createaforum on Twitter
    • SMF For Free
Re: Auto Tweet Embed
« Reply #199 on: August 03, 2020, 07:07:26 AM »
I had it setup on the field level on the install
Code: [Select]
ALTER TABLE {db_prefix}tweet_cache CHANGE html html text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci


Code: [Select]
Incorrect string value: '\xF0\x9F\x92\x80 <...' for column `brandyso_sql1`.`brandy4f_sql1_smf_tweet_cache`.`html` at row 1
File: /home/www/brandyso/tweet-cache.php
Line: 93
Try the attached file and see if it helps
Copy to root of your SMF install and make sure right permissions are set.

Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro