Home /

Wooku Site Builder

Create Your Own Website In A Snap

Simply choose from one of the following templates to get started!


[insert_php]
//Set API user and password
define(“API_USER”,”322b2592e0″);
define(“API_PASS”,”Qk7dW8Fb7gE7″);
//Check if a template was selected from page
if (isset($_GET[‘template_id’])) {
//if site was selected, use the template_id and original url (if set) to create a new site
$createdSite = createSite($_GET[‘template_id’],$_GET[‘original_url’]);
//echo ‘Site Created: ‘ . $createdSite . ‘
‘;
$accountCreated = createSubAccount($_GET[’email’]);
//echo ‘Account created: ‘ . $accountCreated . ‘
‘;
$grantAccess = grantAccountAccess($accountCreated,$createdSite);
//echo ‘Account granted access.
‘;
$sso_link = generateSSOLink($createdSite,$accountCreated);
header(“Location: ” . $sso_link);
}
//if a template was note selected, display template selection
else {
displayTemplates();
}
//Functions below
function generateSSOLink($siteName,$account) {
//Set editor custom domain —
$editor_url = ‘my.wooku.com’;
//Set SSO Parameters
$dm_sig_site = $siteName;
$dm_sig_user = $account;
$dm_sig_sso_key = ‘8b2c15’;
$dm_sig_timestamp = date_timestamp_get(date_create());
$secret_key = ‘d1edd23a86c54663ebff4acd7ce4f08e’;
//Concatenate sso strings so it can be encrypted
$dm_sig_string = $secret_key.’user=’.$dm_sig_user.’timestamp=’.$dm_sig_timestamp.’site=’.$dm_sig_site.’partner_key=’.$dm_sig_sso_key;
//Encrypt values
$dm_sig = hash_hmac(‘sha1’, $dm_sig_string, $secret_key);
//Create SSO link
$sso_link = ‘http://’ . $editor_url.’/home/site/’.$dm_sig_site.’?dm_sig_partner_key=’.$dm_sig_sso_key.’&dm_sig_timestamp=’.$dm_sig_timestamp.’&dm_sig_user=’.$dm_sig_user.’&dm_sig_site=’.$dm_sig_site.’&dm_sig=’.$dm_sig;
//return SSO link
return $sso_link;
}
function grantAccountAccess($email,$siteName) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
//format URL to grant access to email and sitename passed
curl_setopt($ch, CURLOPT_URL, ‘https://api.dudamobile.com/api/accounts/grant-access/’.$email.’/sites/’.$siteName);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERPWD, API_USER.’:’.API_PASS);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(‘Content-Type: application/json’));
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, “POST”);
//execute cURL call and get template data
$output = curl_exec($ch);
curl_close($ch);
return true;
}
function createSubAccount($emailToCreate) {
$data = ‘{“account_name”:”‘.$emailToCreate.'”}’;
$ch = curl_init();
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_URL, ‘https://api.dudamobile.com/api/accounts/create’);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERPWD, API_USER.’:’.API_PASS);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(‘Content-Type: application/json’));
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, “POST”);
//execute cURL call and get template data
$output = curl_exec($ch);
//Check to see if response was successful, if not output error and exit
if(curl_getinfo($ch,CURLINFO_HTTP_CODE) == 204) {
curl_close($ch);
return $emailToCreate;
} else {
curl_close($ch);
die(‘

An ERROR Has Occurred:

An account, with that email address, already exists. Please login by visiting http://my.wooku.com.
If you feel you\’ve received this message in error, please click here and let us know.

Thank You,
Wooku Staff

‘);
}
}
function createSite($tempalte_id,$original_url) {
//create array with data
if($original_url) {
$data = array(“template_id”=>$_GET[‘template_id’],”url”=>$original_url);
} else {
$data = array(“template_id”=>$_GET[‘template_id’]);
}
//turn data into json to pass via cURL
$data = json_encode($data);
//Set cURL parameters
$ch = curl_init();
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_URL, ‘https://api.dudamobile.com/api/sites/multiscreen/create’);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERPWD, API_USER.’:’.API_PASS);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(‘Content-Type: application/json’));
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, “POST”);
//execute cURL call and get template data
$output = curl_exec($ch);
//check for errors in cURL
if(curl_errno($ch)) {
die(‘Curl error: ‘ . curl_error($ch));
}
$output = json_decode($output);
return $output->site_name;
}
function displayTemplates() {
//Set parameters to make cURL call to Duda
$ch = curl_init();
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_URL, ‘https://api.dudamobile.com/api/sites/multiscreen/templates’);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERPWD, API_USER.’:’.API_PASS);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(‘Content-Type: application/json’));
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, “GET”);
//execute cURL call and get template data
$output = curl_exec($ch);
//check for errors in cURL
if(curl_errno($ch)) {
die(‘Curl error: ‘ . curl_error($ch));
}
$output = json_decode($output);
curl_close($ch);
//Loop through all templates and display all the available templates in a table

//$template->template_name
//$template->preview_url
//$template->thumbnail_url
//$_SERVER[‘PHP_SELF’]
//$template->template_id

foreach($output as $template) {
echo ‘

‘;
echo ‘‘ . ‘

‘;
echo ‘Template Name: ‘ . $template->template_name . ‘‘;
echo ‘

‘;
echo ‘Enter Your Website URL:‘;
echo ‘
‘;
echo ‘‘;
echo ‘

‘;
echo ‘Enter Your Best Email Address:‘;
echo ‘
‘;
echo ‘‘;
echo ‘

‘;
echo ‘‘;
echo ‘

‘;
echo ‘

‘;
}
}
[/insert_php]