API integration for dummies

Learn the basics on how to integrate Signaturit's API into your system.

In this short tutorial we will guide you step by step to create a simple integration. 

REQUIREMENTS

Before diving into the code, you will need to setup your environment to create your PHP web application.

1. Text Editor:

First of all, you will need a text editor in order to code this tutorial. We recommend you to download Atom Editor for free. 

2. XAMPP:

To execute PHP code you will need to install the language and a web server to create the webpage. XAMPP is a prepared package that includes the language PHP, Apache Web Server and MySQL
database (you will not need this for this tutorial, but it’s already included in the bundle).

Download XAMPP from their website.

3. Composer:

Composer is a package manager for PHP. It allows you to install a lot of libraries that are available online, ready to be downloaded and used in your projects.

Download Composer and follow the screen instructions.

4. Signaturit's PHP SDK:

You will need this to create the "send.php" script that will create the API request to Signaturit. This will also help to speed up the integration process with our platform.

SDK Download and more information

5. Signaturit's basics:

Register a new account in our Sandbox environment and have your token and all the basic documentation at hand. 

CODE

1. Test the XAMPP installation:

To test it, use the text editor to create a file named info.php in: c:\xampp\htdocs\info.php with the content below:

<?php
phpinfo();

Open your browser and go to http://localhost/info.php. You should see something like:

This confirms that PHP and XAMPP are installed successfully and you can start working in the integration.

2. Create your project folder: 

Create a folder in C:\xampp\htdocs with the name “Signaturit”. This is the folder where we are going to
place our files.

3. Create your HTML form: 

In your text editor, create a new file called “index.html” and copy the content below:

<!DOCTYP html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>Signaturit</title>
</head>
<body>
<h3>Please fill-out the following form:</h3>

<form method="post" action="send.php">
First name: <input type="text" name="name" />
<br>
Email Address: <input type="text" name="email" />
<br>
<hr>
<input type="submit" value="Submit" />
</body>

</html>

This is a simple form that will submit in "send.php" the information stated in the fields.

4. Install the composer: 

Create a file named “composer.json” in the project's folder with the following content:

{
"require": {
"signaturit/signaturit-sdk": "^1.0"
}
}

Now, open the Command Prompt and go to the project's folder.

Execute the command “composer install”.

If everything goes well, you will see a new folder called “vendor” in the Signaturit folder.

5. Create the "send.php" file:

The "send.php" file will handle the information submitted in the HTML form and will send it to Signaturit.

Create a file called "send.php" with this content and save it in your project's folder.

<?php
require_once __DIR__.'/vendor/autoload.php';
$client = new Signaturit\Client('LxSOTPJUsvDaFaENENuLiOoHvRFVyusIBXarOaEtQnCQWpjznUmRURGCemiIzNCRTPQPMQpRiPuNkxEQQwRHaZ');

$response = $client->createSignature(
[],
[
'name'=> $_POST['name'],
'email' => $_POST['email'],
],
[
'templates' => ['#test'],
'delivery_type' => 'url',
]
);
?>

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html"; charset="utf-8">
<title>Signaturit</title>
</head>
<body>
<h3>Please sign the document:</h3>
<iframe src="<?php echo $response['url'] ?>" width="800" height="600"</iframe>
</body>
</html>

6. Create a template:

Create a template in Signaturit and name it "#test". Check this tutorial to know how to create a template

This will be the test document to be signed. 

TEST YOUR CODE

Go to http://localhost/signaturit and check the results.

Fill-out the information and click on "Submit". You will see the #test document template ready to be signed. 

  • HTML Form: 

 

  • Signing application: 

Have more questions? Submit a request

0 Comments

Article is closed for comments.
Powered by Zendesk