Log In  |  Sign Up  |  Help

Presale preview

Overview

Create a preview to show what the visitor’s desktop site will look mobile-optimized.

Target Audience:

Existing DudaDesign partners or companies looking to generate leads or excitement instantly by displaying a preview of what their customers’ websites can look like on mobile.

Available for:

Anyone. The Before & After preview is only available for DudaDesign or DudaWhite partners.

Essentials before getting started:

  1. Make sure you are a DudaWhite or DudaDesign partner and have set up your customized editor, dashboard, login and domains.
  2. Requested API access and been approved. Have your API user and password keys ready.
  3. Create an input form on your website asking users to enter a site url.

Steps to implement the usecase:

Download Full implementation code: PreSalePreview.php.zip

1) Create Site

In order to show a preview, we must create a site to display it. You will create a mobile site based on the provided URL.

API URL:

https://api.dudamobile.com/api/sites/create

Parameters:

site_data

original_site_url - the base URL of the website you want to convert (mandatory)

Success response code: [http_code] => 200

Success response: site_name

PHP Code example: (replace {parameter} with actual value)

<?php
	$data = '
		{	
		"site_data":
			{
				"original_site_url":"{original_site_url}"
			}
		}
	';
	$ch = curl_init();
	curl_setopt($ch, CURLOPT_URL, 'https://api.dudamobile.com/api/sites/create');
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
	curl_setopt($ch, CURLOPT_USERPWD, "{your_api_username}:{your_api_password}");
	curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
	curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
	curl_setopt($ch, CURLOPT_POST,1);
	curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
	curl_setopt($ch, CURLOPT_HTTPHEADER, array(                                                                          
		'Content-Type: application/json', 		
		'Content-Length: ' . strlen($data))                                                                       
	);  
$output = curl_exec($ch);
	curl_close($ch);
?>

2) Get Site Preview URL

API URL: https://api.dudamobile.com/api/sites/{site_alias}

URL Parameters: site_alias - your site alias which you created in step a. (mandatory)

Parameters: none

Success response code: [http_code] => 200

PHP Code example: (replace {parameter} with actual value)

<?php
	$data = '';

	$ch = curl_init();
	curl_setopt($ch, CURLOPT_URL, 'https://api.dudamobile.com/api/sites/{site_alias}');
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_USERPWD, "{your_api_username}:{your_api_password}");
	curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
	curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
	curl_setopt($ch, CURLOPT_HTTPHEADER, array(                                                                          
		'Content-Type: application/json', 		
		'Content-Length: ' . strlen($data))                                                                       
	);   
//Perform cURL and set result as $output
$output = curl_exec($ch);
//Decode JSON results into array
$output = json_decode($output);
curl_close($ch);
//Echo exact preview URL from array
echo $output->site_extra_info->preview_url;
?>

The above code will output the preview URL for you to share with your customers.