Add a Tweet BBcode to a phpBB Forum

July 5, 2012 — 7 Comments

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.

7 responses to Add a Tweet BBcode to a phpBB Forum

  1. So I just need to put this in the HTML file of my board and voila?

    • 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. :)

  2. Been looking for something like this for a while so this is great, thanks. You need a closing though :)

    • 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?

      • 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.

  3. Yes, I did – darn WordPress trying to be helpful ;)

    On my forum, I needed to add it or it threw things out of whack. May be just my forum though.

    Thanks again :)

  4. Thanks. Good stuff there :)

Leave a Reply