views:

48

answers:

2

I’m trying to display a swf from another site into mine.

I’ve got permission from the other side to do so I’m just having problems figuring it all out.

I’d like to display just the swf not the entire page that swf is on.

I’ve tried this – but it only seems to work with content and I haven’t had any luck getting the swf to appear.

<?php $conts = file_get_contents('http://www.test.com/');
$pattern = '~<div.*id="content".*>(.*)</div>~iUs';
preg_match($pattern, $conts, $matches);
array_shift($matches);
echo $matches[0]; ?>

How can a go about doing this. Thanks!

+1  A: 

I'm not sure I understand your question :-? but I believe you could use something like this. Create an embed object on your site and in it's src point it to the external swf. Will that work ?

nc3b
Agreed. Is this swf name changing all the time or something. What does 'http://www.test.com/' content look like?
Josh Pinter
Thanks that sort of did the trick... The only thing is the swf connects to a database and this solution didn't seem to work. So I'll just end up using an iframe for now.
Adam
A: 

Well, you can't just grab the div that have the SWF, you need to grab the URL of the SWF. For instance, instead of doing this $pattern = '~<div.*id="content".*>(.*)</div>~iUs'; try something like $pattern = '~<embed.*src=".+".*>.*</embed>~iUs';

That way you'll getting the src of the SWF, along with the embed tag, which you can use in your site.

Ben