Getting Started

Below you will find tutorials that will teach you how to use linkvault, and reference documentation.

A Simple Example

Prerequisites:
  • A web server with PHP enabled
  • Knowledge of HTML and PHP

This tutorial helps you set up your first secure download link with linkvau.lt. If you need help you can also check out common questions, or email support linkvault@clearmediawebsites.co.uk.

linkvau.lt is designed as a simple API to allow you to generate secure download links for your digital content. We've made it as simple as possible to connect to the API and secure your files, however there's a bit of technical know-how required.

This tutorial uses PHP, HTML and CSS but the principles can be applied to the programming language of your choice.

This tutorial shows you how to get started using a simple example of a download link that can only be accessed once a user has registered.
Step 1: Get your API key

To get started, you will need to find your API key in your linkvau.lt dashboard. This is displayed at the top of the page when you log in, and should look something like this:


56dd703295d9f18cd74140bf6c1a7f8cfaa72200
Step 2: Choose whether you're uploading your file, or letting us know where to find it.

The next step is to upload your file(s). We can accept almost any type of file and are currently allowing files up to 1GB.


Step 3: Upload your file, or let us know where to find the file.

The next step is to upload your file(s). We can accept almost any type of file and are currently allowing files up to 1GB.


Step 4: Grab the file ID

Every file uploaded into linkvau.lt is allocated a unique ID. In order to generate our secure download links we need this file id. You will find it here:


Step 5: Download the API

Now you're gonna need the linkvau.lt API code. You can download it here

NOTE: All the files detailed below are also provided in the API download for your convienience. Instead of creating new files, you can edit our example instead.
Step 6: Create an HTML form

Create two files, one called index.php and and another called download-page.php. Add the following code into the index.php page.

	<form method="post" action="download-page.php">
		<label for="name">Name</label><br />
		<input name="name" id="name" /><br />
		
		<label for="email">Email</label><br />
		<input name="email" id="email" /><br />
		
		<label for="submit">Submit</label><br />
		<input type="submit" name="submit" id="submit" value="Submit" /><br />
	</form>

This is our registration form. Our users will be using this form to sign up for a download.

We're also going to put our API code we downloaded above into the same folder as these two files. Once you've finished editing index.php copy api.php into the same folder as your two new files. Your folder structure should look something like this:

Step 7: Register your user

The next step is to register your user. We're going to keep this example fairly simple, but you might want to save your user's details to a database or email them somewhere.

Open up download-page.php and add the following code.

	<?php	
	// Include the linkvault API
	include_once('./api.php');	
	
	// Grab the user input from the form
	$name = $_POST['name'];
	$email = $_POST['email'];
	
	function save_user_details($name, $email) {
		// Save the user details to a database here
	
		return TRUE;
	}
	
	// What we are doing here is calling the save
	// user details function, if the function succeeds
	// we will call the linkvau.lt api and get a secure
	// download link to display to our user
	if(save_user_details($name, $email) == TRUE) {
		$api = new LinkvaultApi('your-api-key' );
		$link_url = $api->get_download_url('your-file-id');
		if($link_url != '') {
			echo '<a href="' . $link_url . '">Click here to download the file</a>';
		} else {
			echo 'There was a problem';
		}    		
	}
	?>
Step 8: Configure the code

The final step is to configure the code in download-page.php so that it can talk to our API.

All we need to do is add in our API key and our file id. The example below uses the API key and file ID displayed in this help guide.

	// Change this line as follows:
	// $api = new LinkvaultApi('your-api-key');
	// $link_url = $api->get_download_url('your-file-id');
	
	// These lines are using an example API key and file ID, you should use your own
	$api = new LinkvaultApi('56dd703295d9f18cd74140bf6c1a7f8cfaa72200');
	$link_url = $api->get_download_url('abd84hji');
Step 9: That's it!

That's it, you're ready for testing. Upload the files to your web server, load up the index.php file and click submit. You should see a secure download link.

The API

We've tried to keep the API as simple as possible. The API is restful and very easy to use:

The GET LINK method

The URL is as follows and is accessed via a GET request:

http://linkvau.lt/api/get/link/{api-key}/{file-id}

Where the API key and the File ID are the API key from your account and the file ID for the file you uploaded. If the API call is successful (i.e. your API Key and File ID are correct) calling this URL will return a valid JSON object constructed as follows:

	{
		"link":"http:\/\/link-to-single-use-download-url-of-your-file",
		"result":"success"
	}

If your API call is incorrect, the API will respond with the following JSON:

	{
		"link":"",
		"result":"failure",
		"reason":"The reason for the failure"
	}

If the result is a success, the link variable will be a link to the download URL of your file.

The GET FILES method

The URL is as follows and is accessed via a GET request:

http://linkvau.lt/api/get/files/{api-key}/

Where the API key is the API key from your account. If the API call is successful (i.e. your API Key and File ID are correct) calling this URL will return a valid JSON object constructed as follows:

	[
	    {
	        "id": "GCAnk8v9",
	        "filename": "help.txt"
	    },
	    {
	        "id": "IEc2ZTPw",
	        "filename": "readme.txt"
	    }
	]

The POST URL method

The URL is as follows and is accessed via a POST request:

http://linkvau.lt/api/add/url/{api-key}/

The POST request should contain the following JSON

    [
    	{
    		"url_source":"http:\/\/link-to-http-address-of-your-file/",
    		"downloads_per_link": 3,
    		"link_expires_after": 3
    	}
    ]
				

"clicks_per_generated_link" is the number of clicks allowed per download link.
"link_expires_after" is the time in hours for the link to remain valid.

Where the API key is the API key from your account. If the API call is successful (i.e. your API Key and File ID are correct) calling this URL will return a valid JSON object constructed as follows:

	[
	    {
	        "result": "success",
	        "file_id": "the link id"
	    }
	]

Upcoming Features

We are working on the following upcoming features for the API:

  • Facility to send an email address with the API call to store your customer's email addresses (and possibly send automated emails to them)
  • Ability to create customised error pages
  • Ability to redirect users on failure