loading Loading...
add chat to your website

How does the API allow me to capture learners data and insert it into my own database/website?

Using our API, you can easily capture course taker's data on your website. 

 

Example Use Cases of Capture API

  • Obtain 'leads' into your database, information such as name, email, etc. of course takers.
  • Aquire 'contacts' of people taking your course in SalesForce, or any other CRM system.
  • Triggering emails or any other process on your website when someone takes the course.

 

How it Works

This feature requires minor programming effort at your side to accept the data sent by ProProfs. Please note that this API is supported only in some of our high-end premium packages such as those for business and enterprises.

 

To get started, you would need to make a file (your callback script) which will accept the data sent by the course through 'REQUEST' method. Whenever someone takes your course, it will call your callback script to accept the data. After accepting the data, you can write any custom code such as required for inserting the data into your database or CRM or triggering some business logic process.
  

Please follow the step mentioned below to setup callback URL:

 

Go to the Settings page, click on "Notifications" and check the box under the label "Notification via API."  Type the call back URL indicating where the script is on your site and hit Save. It is the URL of the script which will accept the data in REQUEST method.

 

*The below screenshot is an example used to depict the live scenario, in this example we use a PHP path as the call back URL indicating server location of data storage. Users have to use the call back URL in their script for the server location of data storage. 

 

 

 

There are 15 total attributes which we support and pass them to REQUEST when someone takes your course. It is similar to REST or SOAP API's.  
 
You would use the REQUEST array method to capture the course attempt information. ProProfs Training Maker will call your callback URL and will post all of these variables to that particular script. Please see all the 15-course attributes(variables) below:
 
An Example: PHP and MySQL
If you are using PHP as server scripting, you can use the following example to test this feature.
 
 
Step 1: SQL: Create a table with the following SQL query:
 
<?php
	
	CREATE TABLE `course_takers` (
	`test_id` int(11) NOT NULL auto_increment,
	`result_id` int(100) NOT NULL,
	`course_id` int(100) NOT NULL,
	`name` varchar(150) NOT NULL,
	`email` varchar(150) NOT NULL,
	`id` varchar(150) NOT NULL,
	`phone` varchar(150) NOT NULL,
	`address` varchar(150) NOT NULL,
	`city` varchar(150) NOT NULL,
	`state` varchar(150) NOT NULL,
	`pincode` int(100) NOT NULL,
	`country` varchar(150) NOT NULL,
	`ip` varchar(150) NOT NULL,
	`time_taken` varchar(150) NOT NULL,
	`completed` int(100) NOT NULL,
	`attempt_date` timestamp NOT NULL,
	PRIMARY KEY  (`test_id`)
	)
	
	?>
 
 
Step 2: PHP: Click here to download the PHP script (get_course_takers_data.php) file, and upload it on to your web server.
 
<?php
	/*--------------------------------------------------------------------------
	This is a basic example of the feature:
	"Allow capturing course taker's data for inserting in my own database/website"
	
	More Info & Help: http://support.proprofs.com/kb/questions/104/
	
	Contact Us: http://support.proprofs.com/kb/contact.php
	
	ProProfs.com
	---------------------------------------------------------------------------*/
	
	//Do all database configuration here per your web server configurations 
	$link = mysql_connect('localhost', 'mysql_user', 'mysql_password');
	if (!$link)
	{
		die('Could not connect: ' . mysql_error());
	}
	
	// Decide whether this is new attempt information or update request after assigning bonus points
	if($_REQUEST['status'] == "new")
	{
		// Means this is new attempt record for inserting into database
		$sql_query = "INSERT INTO course_takers SET
		result_id='".$_REQUEST['result_id']."' ,
		course_id='".$_REQUEST['course_id']."' , 
		name ='".$_REQUEST['name']."', 
		email ='".$_REQUEST['email']."',
		id ='".$_REQUEST['id']."', 
		phone ='".$_REQUEST['phone']."',
		address ='".$_REQUEST['address']."',
		city ='".$_REQUEST['city']."', 
		state ='".$_REQUEST['state']."',
		pincode ='".$_REQUEST['pincode']."', 
		country ='".$_REQUEST['country']."', 
		ip ='".$_REQUEST['ip']."', 
		time_taken ='".$_REQUEST['time_taken']."', 
		completed ='".$_REQUEST['completed']."', 
		attempt_date='".$_REQUEST['attempt_date']."'"; 
	}
	else if($_REQUEST['status'] == "update")
	{
		// Means bonus points has been assigned and this is update request to update already stored attempt record.
		$sql_query = "UPDATE course_takers SET
		completed='".$_REQUEST['completed']."' ,
		time_taken='".$_REQUEST['time_taken']."' 
		WHERE result_id='".$_REQUEST['result_id']."' 
		LIMIT 1";
	}
	else
	{
	// This block will never execute because status will either contains "new" or "update"
	}
	//Run query
	$query_run = mysql_query($sql_query);                    
	
	//Rest of the code here...(per your needs)
	
	?>

 

 

Troubleshooting Guide:

If you are having trouble making the API work, try the following troubleshooting steps:

  1. ProProfs originates all requests from public facing IP '67.228.18.170'. Ensure that this IP is not blocked. 
  2. After unblocking the IP, check if you are receiving requests from our server. You can execute the snippet titled 'course_response_test.php' on your server. Change the email address in this script to your email id. Then update the callback URL of the course under "Edit Settings" -> "Notifications" to call this URL. Check if you receive an email after you complete the course. It validates if responses from ProProfs are reaching your server.

 

 

Click here to download the PHP script (course_response_test.php)

 

Related article: How does the Single Sign-On (SSO) integration feature work?

 

Feel free to contact us, if you need further assistance.