Add a Tweet BBcode to a phpBB Forum

I was looking for a way to embed a tweet into phpBB using the BBcode funcationality. I found a decent solution but edited it a tiny bit (to account for http vs https URLs).

BBcode usage:

[tweet]{SIMPLETEXT1}://twitter.com/{SIMPLETEXT2}/status/{IDENTIFIER}[/tweet]

HTML replacement:

<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={IDENTIFIER}&callback=loadx"></script>
<div class='twitter' onLoad='loadx().html'/></div>

Here’s the result:

Thanks to Evan Hoffman.

[socialbuttons]

Karl Smith is a New Zealander living in Melbourne, Australia. He's an art and design, tech, and pop culture enthusiast. Previous gigs include musician, concierge, picture framer, designer and product manager.