vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Automatically embedding Tweets (https://vborg.vbsupport.ru/showthread.php?t=322138)

greigeh 03-16-2016 10:13 PM

Automatically embedding Tweets
 
I already have the following plugin installed on my forum:

Code:

$embed_player =  '
    <table widht="300" align="center" class="tborder" >
    <tr><td class="alt1">
    <iframe src="http://vine.co/v/\\4/card" frameborder="0" width="300" height="300"></iframe>
      </td>
      </tr>
      </table>
      ';

      $post['message'] = preg_replace('#(<a href="http://vine.co)?/(embed/([-|~_0-9A-Za-z]+)|v\/([-|~_0-9A-Za-z]+)&?.*?)">(http://vine.co)?/(embed/([-|~_0-9A-Za-z]+)|v\/([-|~_0-9A-Za-z]+)&?.*?)<\/a>#i', $embed_player, $post['message']);

Which automatically embeds vines, but i'm not very smart when it comes to JavaScript/PHP etc so have been unable to try and change the specs of this into ones that are Twitter.

We have a Twitter BBCode which you do [Twitter]TWEET ID[/Twitter] but this is a painful process. For our users. But rather just would post their URL to tweet (e.g. https://twitter.com/name/status/tweet-ID ) and would auto embed. Only Tweet ID is needed for the bbcode below

Code:

<div>
<script type="text/javascript">
function loadx(data) {
  document.write(data.html);
}
</script>
<script type="text/javascript" src="https://api.twitter.com/1/statuses/oembed.json?id={param}&callback=loadx"></script>
<div class="twitter" onLoad="loadx().html"/>
</div>
</div>
<div style="clear:both;"></div>

Is there any quick easy way to put the second code, into the first?

--------------- Added [DATE]1458246420[/DATE] at [TIME]1458246420[/TIME] ---------------

tried something along the lines of

Code:

$embed_player =  '
<div> <script type="text/javascript"> function loadx(data) { document.write(data.html); } </script>
 <script type="text/javascript" src="https://api.twitter.com/1/statuses/oembed.json?id=\4&amp;callback=loadx"></script> <div class="twitter" onLoad="loadx().html"/> </div> </div> <div style="clear:both;"></div>


      ';

      $post['message'] = preg_replace('#(<a href="http://twitter.com)?/[\w-]+|+/status[es]*\/([\d]+)]+)&?.*?)">(http://twitter.com)?/[\w-]+|+/status[es]*\/([\d]+)]+)&?.*?)<\/a>#i', $embed_player, $post['message']);

but this failed as not sure what i'm doing at all lol!


All times are GMT. The time now is 05:55 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01148 seconds
  • Memory Usage 1,714KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (3)bbcode_code_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (1)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete