Welcome Guest [Log In] [Register]
We hope you enjoy your visit.

You're currently viewing our forum as a guest. This means you are limited to certain areas of the board and there are some features you can't use. If you join our community, you'll be able to access member-only sections, and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free.


Join our community!


If you're already a member please log in to your account to access all of our features:

Username:   Password:
Locked Topic
[ ! ] BBCode to embed tweets
Topic Started: Jun 22 2013, 12:38 PM (1,327 Views)
Lout
Member Avatar
Member
[ *  *  *  *  * ]
Board Address: Private
Board Software: ZetaBoards
Description: Twitter offers the option to embed tweets, however the format is HTML as shown below.

Code: HTML
 
<blockquote class="twitter-tweet"><p>Beer + BBQ = heaven</p>— Lout (@LoutOfOrder) <a href="https://twitter.com/LoutOfOrder/statuses/341585937005940737">June 3, 2013</a></blockquote>
<script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script>


Which results in the following -

Posted Image

I'd like to be able to embed these in posts, is there a way of doing it?

Thanks in advance :)
Offline Profile Goto Top
 
Cory
Member Avatar
Coder
[ *  *  *  *  *  *  *  * ]
Do you mind using this for the BBCode syntax?
Code:
 
[twitter=Lout; June 3, 2013; LoutOfOrder/statuses/341585937005940737]Beer + BBQ = heaven[/twitter]
Offline Profile Goto Top
 
Lout
Member Avatar
Member
[ *  *  *  *  * ]
That will be fine Cory
Offline Profile Goto Top
 
Cory
Member Avatar
Coder
[ *  *  *  *  *  *  *  * ]
Use this instead to allow that syntax:
Code:
 
<script type="text/javascript">
//<![CDATA[
$('td:contains([/twitter]), div.search_results:contains([/twitter])').each(function () {
$(this).html($(this).html().replace(/\[twitter=(.+?);(.+?);(.+?)\](.+?)\[\/twitter\]/gi, '<blockquote class="twitter-tweet"><p>$4</p> $1 (@) <a href="https://twitter.com/$3">$2</a></blockquote>'));
if ($(this).find('blockquote.twitter-tweet a').length) {
if ($(this).find('blockquote.twitter-tweet a').attr('href').split(' ')[1].length) {
var sSpace = $(this).find('blockquote.twitter-tweet a').attr('href').split(' ')[1];
$(this).find('blockquote.twitter-tweet a').attr('href', 'https://twitter.com/' + sSpace);
}

var user = $(this).find('blockquote.twitter-tweet a').attr('href').split('twitter.com/')[1].split('/')[0];
$(this).find('blockquote.twitter-tweet').html($(this).find('blockquote.twitter-tweet').html().replace(/@/gi, '@' + user));
}
});
//]]>
</script>

<script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script>
Offline Profile Goto Top
 
Lout
Member Avatar
Member
[ *  *  *  *  * ]
That works, I'm guessing that the bits entered in the BBCode are pretty irrelevant as using the following gives exactly the same result?

Code:
 
[twitter=*; *, *; LoutOfOrder/statuses/341585937005940737]*[/twitter]


Which makes me wonder if it's possible to simplify it so only the following would be required?

Code:
 
[twitter=LoutOfOrder/statuses/341585937005940737][/twitter]


or even

Code:
 
[twitter]LoutOfOrder/statuses/341585937005940737[/twitter]
Offline Profile Goto Top
 
Cory
Member Avatar
Coder
[ *  *  *  *  *  *  *  * ]
I can alter the regexp for a more precise match, but what you have in mind doesn't appear to be workable:
Firebug Console
 
Load denied by X-Frame-Options: https://twitter.com/ does not permit cross-origin framing.
Offline Profile Goto Top
 
Quozzo
Member Avatar
Only in death does duty end
[ *  *  *  *  * ]
You need to use the twitter api which uses JSONP to send the data. If Cory doesnt want to do it I will but wont be able to until next week.
Offline Profile Goto Top
 
Lout
Member Avatar
Member
[ *  *  *  *  * ]
Thanks guys, I'm in no rush :)
Offline Profile Goto Top
 
Cory
Member Avatar
Coder
[ *  *  *  *  *  *  *  * ]
Go ahead, Quozzo. I no nothing of JSONP at this time.
Offline Profile Goto Top
 
Quozzo
Member Avatar
Only in death does duty end
[ *  *  *  *  * ]
JSONP is basically a cross domain ajax request, but the data returned is really just a js object.

I can do it but it will take a while.
Offline Profile Goto Top
 
Quozzo
Member Avatar
Only in death does duty end
[ *  *  *  *  * ]
Twitter have changed their API so i wont be learning a new method, sorry for the wait.
Offline Profile Goto Top
 
Lout
Member Avatar
Member
[ *  *  *  *  * ]
No worries, thanks for looking anyway.
Offline Profile Goto Top
 
Roby
Member Avatar
#41

This request was deemed impractical by our staff. This could mean that the feature you have requested is impossible to write, requires PHP and/or hosting, or requires too many AJAX requests. If you have any questions about why this request is not practical, feel free to contact Roby .
Offline Profile Goto Top
 
1 user reading this topic (1 Guest and 0 Anonymous)
« Previous Topic · Closed Requests · Next Topic »
Locked Topic