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]

7 Comments

    1. Hiya, you need to go to your admin panel > posting > BBcodes.

      Then add a new BBcode. You’ll see the two fields to complete: “bbcode” and “html replacement”. Fill those in and save. :)

    1. Dave, do you mean a closing “/div” ? (I think the comment box removed your code if you typed some there)… I just rechecked my forum and it seems to work exactly as per my post… maybe phpBB is smart enough to auto-close it?

      1. Hi.

        Thanks for the example, it works great, but has dpmcalister said, it’s better with a . On my phpbb, it works fine without, but when a post a tweet, the following signature has a wrong font and size. So just add the closing /div if you see a font glitch or something else.

Leave a Reply