Using the Spreadshirt Flash Shop

Because Flash won't read data outside of it's own domain (for security reasons) you need to use a proxy script to relay requests from Flash to the service. (Unfortunately Spreadshirt's crossdomain.xml isn't open enough, which is probably understandable.) The PHP proxy script example below is a first attempt and has not been checked for security etc., so use it at your own risk!

Using this proxy also means:

  • you have to supply your own version of the WSDL file with an appropriate change to the soap:address element (at the bottom of the file)
  • and you'll have to update the urls in Service.as file and recompile the movie.

I'll post examples when I get time.

If you have a lot of articles or designs in your shop, shifting all this XML around can really slow things down. In reality, I think it would be better to do most of the heavy lifting with a more complete PHP script and supply the data to the Flash movie in a more lightweight format such as JSON, AMF or SWX

<?php
 
define ('HOSTNAME', 'http://www.spreadshirt.net/');
$path = 'services.php';
$url = HOSTNAME.$path;
 
$session = curl_init($url);
 
$postvars = file_get_contents("php://input");
 
//########## Logging ##############*/
$entryDelim = "\n\n______________________________________\n\n";
$logEntry = $postvars . $entryDelim;
$fp = fopen("postedVars.txt", "a");
fwrite( $fp, $logEntry);
fclose($fp);
 
curl_setopt ($session, CURLOPT_POST, true);
curl_setopt ($session, CURLOPT_POSTFIELDS, $postvars);
 
curl_setopt($session, CURLOPT_HEADER, false);
curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
 
$xml=curl_exec($session);
header("Content-Type: text/xml");
echo $xml;
 
//curl_setopt($session, CURLOPT_FILE, $fp);
 
curl_close($session);
 
?>
flash_shop/php_proxy_script.txt · Last modified: 2009/06/28 15:56 by thuperadmin
 
Recent changes RSS feed Driven by DokuWiki