vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Automatically embed tweet when user posts link (PHP) (https://vborg.vbsupport.ru/showthread.php?t=318389)

greigeh 04-23-2015 03:58 PM

Automatically embed tweet when user posts link (PHP)
 
I already have this plugin for youtube videos/vines/instagram etc but i'm struggling to get it to work with tweets.

PHP Code:

$embed_player =  '
     <table widht="300" align="center" class="tborder" >
     <tr><td class="alt1">
     <iframe src="[B]http://instagram.com/p/\\4/embed/[/B]" frameborder="0" width="280" height="330" scrolling="no"></iframe>
      </td>
      </tr>
      </table>
      '
;

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

I only need help with lines (src="http://instagram.com/p/\\4/embed/")

and

(preg_replace('#(<a href="http://instagram.com)?/(embed/([-|~_0-9A-Za-z]+)|p\/([-|~_0-9A-Za-z]+)&?.*?)">(http://instagram.com)?/(embed/([-|~_0-9A-Za-z]+)|p\/([-|~_0-9A-Za-z]+)&?.*?)<\/a>#i')


below is an example of a link a user would post

https://twitter.com/greigeh/status/590850852161740801

but the script will run with the following html/javascript

HTML 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=[B]TWEET NUMBER HERE[/B]&callback=loadx"></script>
<div class="twitter" onLoad="loadx().html"/>
</div>
</div>
<div style="clear:both;"></div>

So all I really need to know is how to ignore the underlined part of a posted link and place it into this plugin, does that make sense?

sorry if this is so confusing im just a tad baffled at the mo! :eek:

dany_danay 05-20-2018 06:56 AM

Did you get it?

lacidious 07-11-2019 01:18 AM

Did you figure this out? And also, how do I set this up for Vine and Instagram? Thanks!


All times are GMT. The time now is 05:20 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.01093 seconds
  • Memory Usage 1,723KB
  • 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
  • (1)bbcode_html_printable
  • (1)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (3)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