10.09.08

Creating a php proxy for flash

Posted in php at 11:16 pm by rbezemer

So I’m planning on updating my photobucket samples, but I wanted a live flash file on my site instead of the crappy static image I had before. Unfortunaly since the coverflow component requires access to the BitmapData to create the reflection, loading any external images will throw an error. Since Photobucket doesn’t have a crossdomain.xml file yet, the best way to do this is with a simple php proxy to trick flash into thinking it was loaded from your own domain.

Since php is one of those languages I use, but not enough to remember the exact syntax I went searching online.The best example of this I could find was here. There were a few things missing from the script but not a lot. The one major thing I added support for was to verify that the request was coming from the same domain (Sorry but I don’t want everyone cutting and pasting my code and flooding my host with proxy requests and I’m sure you wouldn’t want the same either).

Once the proxy is in place usage is simple. in order to load an image from photobucket:
http://yourserver.com/proxy.php?url=http%3A//www.photobucket.com/some/link/to/image/image.jpg

Anyway here is my modified php code for a simple proxy:

proxy_php