How can my Vyew plugin communicate with my server?

You may want to send information, like form data, or statistics to your own server for storage in a database.

Allowing server access

First, your server must allow the flash plugin SWF to send information to it, by setting up a crossdomain.xml file on your server. Copy and past this text into a file “crossdomain.xml” at the root http docs of your server.

<cross-domain-policy>
<allow-access-from domain=”*” secure=”false”/>
<allow-access-from domain=”vyew.com” secure=”false”/>
<allow-access-from domain=”*.vyew.com” secure=”false”/>
</cross-domain-policy>

Sending the data

Second, there are many ways to send data to your server, such as LoadVars(), XML(), and AMFPHP.
If you are sending a lot of data, consider using AMFPHP.
LoadVars and XML are easier to impliment for simpler data.
Here’s an example:

var data={
name:”myname”,
city:”Berkeley, CA”,
zip:”94111″
}

var lv=new LoadVars(data);
var result=new LoadVars(); //even if not using it, result object is required
lv.x=1; //add data vars to the LoardVars object
lv.y=2;

for(var i in data){ //or add an existing object to it
lv[i]=data[i];
}

//send data to server via POST (default)
lv.sendAndLoad(“http://mydomain/sendvars.php”,result);

You could then access the variables in php:

$_POST['name']
$_POST['zip']
$_POST['city']
$_POST['x']
$_POST['y']

More tutorials on LoadVars and XML

Sending data with LoadVars

Using LoadVars with a MySQL Database

Updated: July 4th, 2013 · Tags:

Post your comment here...

This site uses a Hackadelic PlugIn, Hackadelic SEO Table Of Contents 1.6.0.