greigeh |
03-16-2016 10:13 PM |
Automatically embedding Tweets
I already have the following plugin installed on my forum:
Code:
$embed_player = '
<table widht="300" align="center" class="tborder" >
<tr><td class="alt1">
<iframe src="http://vine.co/v/\\4/card" frameborder="0" width="300" height="300"></iframe>
</td>
</tr>
</table>
';
$post['message'] = preg_replace('#(<a href="http://vine.co)?/(embed/([-|~_0-9A-Za-z]+)|v\/([-|~_0-9A-Za-z]+)&?.*?)">(http://vine.co)?/(embed/([-|~_0-9A-Za-z]+)|v\/([-|~_0-9A-Za-z]+)&?.*?)<\/a>#i', $embed_player, $post['message']);
Which automatically embeds vines, but i'm not very smart when it comes to JavaScript/PHP etc so have been unable to try and change the specs of this into ones that are Twitter.
We have a Twitter BBCode which you do [Twitter]TWEET ID[/Twitter] but this is a painful process. For our users. But rather just would post their URL to tweet (e.g. https://twitter.com/name/status/tweet-ID ) and would auto embed. Only Tweet ID is needed for the bbcode below
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={param}&callback=loadx"></script>
<div class="twitter" onLoad="loadx().html"/>
</div>
</div>
<div style="clear:both;"></div>
Is there any quick easy way to put the second code, into the first?
--------------- Added [DATE]1458246420[/DATE] at [TIME]1458246420[/TIME] ---------------
tried something along the lines of
Code:
$embed_player = '
<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=\4&callback=loadx"></script> <div class="twitter" onLoad="loadx().html"/> </div> </div> <div style="clear:both;"></div>
';
$post['message'] = preg_replace('#(<a href="http://twitter.com)?/[\w-]+|+/status[es]*\/([\d]+)]+)&?.*?)">(http://twitter.com)?/[\w-]+|+/status[es]*\/([\d]+)]+)&?.*?)<\/a>#i', $embed_player, $post['message']);
but this failed as not sure what i'm doing at all lol!
|