Log In  |  Sign Up  |  Help

White Label Self Service Solution

Overview

With DudaWhite, you can now integrate much of the the DudaMobile experience on your own platform. In order to accomplish this, we would create an account, create a new site, grant the newly created account access to the site and finally log the user into the mobile site by performing Single Sign on. After the user is logged in, they will be able to fully customize the mobile website through the editor.

Target Audience:

Companies with an existing user base and account management system who would like to allow their customers to create and edit mobile sites.

Available for: DudaWhite Partners

Essentials before getting started:

  1. Make sure you are a DudaWhite Partner and have set up your customized editor, dashboard, login and domains.
  2. Requested API access and have been approved. Have your API user and password keys ready.
  3. Create a form on your website asking users to enter a site URL and their email address (in case you don’t already have that information) and send the information to a page that will perform the actions below.

Steps to implement the usecase:

Download Full implementation code: DudaWhiteAPI.php.zip

1) Create Account

You will create a DudaWhite sub-account that is related to your master account with Duda. This sub-account will later grant access to edit the site you create. To do this, we will call the /accounts/create URI to create the account with the input data.

API URL: https://api.dudamobile.com/api/accounts/create
Parameters:

  • account_name - your sub account users email address (mandatory)
  • first_name - your sub account users first name (optional)
  • last_name - your sub account users last name (optional)

Success response code: [http_code] => 204

PHP Code Example
<?php
//Set JSON formated message to send to Duda
$data = '
	{	
	  "account_name": "{account_email}", 
	  "first_name": "{account_owner_first_name}", 
	  "last_name": "{account_owner_last_name}"
	}
';
//Initiate cURL 
$ch = curl_init();
//Set cURL parameters
curl_setopt($ch, CURLOPT_URL, 'https://api.dudamobile.com/api/accounts/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))                                                                       
);   
//Perform cURL call and set $output as returned data, if any is returned
$output = curl_exec($ch);
curl_close($ch);
?>

2) Create Site

Now that we have the sub-account created, we also want to create a site to grant access to. To do this, we will POST a message to the /sites/create URI.

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
//Set JSON formated message to send to Duda
$data = '
	{	
	"site_data":
		{
			"original_site_url":"{original_site_url}"
		}
	}
';
//Initiate cURL 
$ch = curl_init();
//Set cURL parameters
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))                                                                       
);   
//Perform cURL call and set $output as returned data, please note the retuned site_name value
$output = curl_exec($ch);
curl_close($ch);
?>

3) Grant sub-account access

Now that we have the sub-account and site created, we want to grant access for the sub-account to the site.

API URL: https://api.dudamobile.com/api/grantaccess/{account_name}/sites/{site_name}
Parameters:

  • account_name (from the account you created above)
  • site_name (from the site you created above as well)

Success response code: [http_code] => 200

 

<?php
$data = '';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.dudamobile.com/api/accounts/grant-access/{previously_created_account_name}/sites/{previously_created_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_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);
?>

4) Perform Single Sign On

After you’ve created a sub-account for your user, a site and granted access, you can perform SSO to log them directly into your branded editor. Head over to our SSO page to see exactly how to implement this last step.

Note:

  • Sub-account users cannot create or delete sites, this must be done by the DudaWhite partner.
  • The login, dashboard and editor pages cannot be customized through the API, they need to be customized by logging directly into the partner account and going to the account settings.