API documentation

MultiURL offers an API to registered users.

Create a new link group or shorten one link

Example below shows you how to send request to MultiURL to either combine several links into one, or shorten a single link.

<?php
// ----- Required fields ----- //
$multiAPI       = 'your api key here';      // Your API key here
$multiFormat    = 'xml';                    // Response format, can be set to either "json" or "xml"
$multiType      = 'group';                  // Set to "group" to combine a group of links or to "single" for one link
$multiLinks     = array(                    // Store your links if $multiType is set to "group"
   'http://www.google.com' => 'Google',
   'http://www.yahoo.com' => '',
);
$multiLink      = 'http://www.google.com';  // Store your link if $multiType is set to "single"

// ----- Optional fields for all link types ----- //
$multiName           = 'My group name';     // Name for your group or link
$multiAlias          = '';                  // Alias for your group or link
$multiPassword       = '';                  // Password for your group or link
$multiToken          = '';                  // Token of existing group you're adding more links to

// ----- Optional fields only for 'group' type ----- //
$multiLinkback       = '1';                 // Show your linkback, "0" for no, "1" to show default, "2" for custom
$multiLinkback_name  = '';                  // Linkback name (if the above is set to "2")
$multiLinkback_url   = '';                  // Linkback URL (if the above is set to "2")

// ----- No need to edit below this line ----- //
$multiURL = 'http://www.multiurl.com/api/create';
$multiParams =
   'api=' . $multiAPI . '&' .
   'format=' . $multiFormat . '&' .
   'type=' . $multiType . '&' .
   'name=' . rawurlencode($multiName) . '&' .
   'alias=' . rawurlencode($multiAlias) . '&' .
   'password=' . rawurlencode($multiPassword) . '&' .
   'linkback=' . $multiLinkback . '&' .
   'linkback_name='. rawurlencode($multiLinkback_name) . '&' .
   'linkback_url='. rawurlencode($multiLinkback_url);
if ( $multiType == 'group' ) {
   if ( $multiToken ) {
      $multiParams .= "&token=$multiToken" .
   }
   foreach ( $multiLinks as $url => $name ) {
      $multiParams .= "&link[]=" . rawurlencode($name) . "\n" . rawurlencode($url);
   }
}
else {
   $multiParams .= "&link=" . rawurlencode($multiLink);
}

$ch = curl_init($multiURL);
curl_setopt($ch, CURLOPT_URL, $multiURL);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $multiParams);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec($ch);
curl_close($ch);

// ----- This is for display purposes ----- //
echo '<pre>'.htmlspecialchars($data).'</pre>';
?>

This will return the following response:

<?xml version="1.0" encoding="utf-8"?>
<multiurl>
   <token>0v</token>
   <short_list_url>http://www.multiurl.com/l/0v</short_list_url>
   <short_toolbar_url>http://www.multiurl.com/g/0v</short_toolbar_url>
   <links>
      <token>8x</token>
      <short_url>http://www.multiurl.com/s/0v</short_url>
      <original_url>http://www.google.com</original_url>
   </links>
   <links>
      <token>8y</token>
      <short_url>http://www.multiurl.com/s/0v</short_url>
      <original_url>http://www.yahoo.com</original_url>
   </links>
</multiurl>

If you would like to convert a single link, you will receive the following response:

<?xml version="1.0" encoding="utf-8"?>
<multiurl>
   <token>8A</token>
   <short_url>http://www.multiurl.com/s/8A</short_url>
   <original_url>http://www.google.com</original_url>
</multiurl>

If something is wrong with your request, you will receive an error in this format:

<?xml version="1.0" encoding="utf-8"?>
<multiurl>
   <error>API key does not seem to be valid.</error>
</multiurl>

Update link group or link

Example below shows you how to send request to MultiURL to update a group or a single link.

<?php
// ----- Required fields  ----- //
$multiAPI       = 'your api key here';      // Your API key here
$multiFormat    = 'xml';                    // Response format, can be set to either "json" or "xml"
$multiType      = 'group';                  // Set to "group" to update a group or to "single" for one link
$multiToken     = '1234';                   // Token of a group or a link to update

// ----- Fields you want to update, delete those you don't want to change  ----- //
$multiUpdate = array(
   'name'          => 'My group name',  // Name for your group or link
   'alias'         => '',               // Alias for your group or link
   'password'      => '',               // Password for your group or link
   'linkback'      => '',               // Show your linkback, "0" for no, "1" to show default, "2" for custom
   'linkback_name' => '',               // Linkback name (if the above is set to "2")
   'linkback_url'  => '',               // Linkback URL (if the above is set to "2")
);

// ----- No need to edit below this line ----- //
$multiURL = 'http://www.multiurl.com/api/update';
$multiParams =
   'api=' . $multiAPI . '&' .
   'format=' . $multiFormat . '&' .
   'type=' . $multiType . '&' .
   'token=' . $multiToken;
foreach ( $multiUpdate as $k => $v ) {
   $multiParams .= '&' . $k . '=' . rawurlencode($v);
}

$ch = curl_init($multiURL);
curl_setopt($ch, CURLOPT_URL, $multiURL);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $multiParams);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec($ch);
curl_close($ch);

// ----- This is for display purposes ----- //
echo '<pre>'.htmlspecialchars($data).'</pre>';
?>

If successful, response will contain a token you have specified in your request along with your group's or link's URLs:

<?xml version="1.0" encoding="utf-8"?>
<multiurl>
<token>0v</token>
<short_list_url>http://www.multiurl.com/l/0v</short_list_url>
<short_toolbar_url>http://www.multiurl.com/g/0v</short_toolbar_url>
</multiurl>

Delete link group or link

Example below shows you how to send request to MultiURL to either remove a group of links, or remove a single link.

<?php
// ----- Required fields  ----- //
$multiAPI       = 'your api key here';      // Your API key here
$multiFormat    = 'xml';                    // Response format, can be set to either "json" or "xml"
$multiType      = 'group';                  // Set to "group" to delete a group of links or to "single" for one link
$multiToken     = '1234';                   // Token of a group or a link to delete

// ----- No need to edit below this line ----- //
$multiURL = 'http://www.multiurl.com/api/delete';
$multiParams =
   'api=' . $multiAPI . '&' .
   'format=' . $multiFormat . '&' .
   'type=' . $multiType . '&' .
   'token=' . $multiToken;

$ch = curl_init($multiURL);
curl_setopt($ch, CURLOPT_URL, $multiURL);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $multiParams);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec($ch);
curl_close($ch);

// ----- This is for display purposes ----- //
echo '<pre>'.htmlspecialchars($data).'</pre>';
?>

If successful, response will contain a token you have specified in your request:

<?xml version="1.0" encoding="utf-8"?>
<multiurl>
<token>1234</token>
</multiurl>

Get group or link details

Example below shows you how to send request to MultiURL to get details of a group or link.

<?php
// ----- Required fields  ----- //
$multiAPI       = 'your api key here';      // Your API key here
$multiFormat    = 'xml';                    // Response format, can be set to either "json" or "xml"
$multiType      = 'single';                 // Set to "group" to get group's details or to "single" for link's details
$multiToken     = '1234';                   // Token of a group or a link to get details for

// ----- No need to edit below this line ----- //
$multiURL = 'http://www.multiurl.com/api/info';
$multiParams =
   'api=' . $multiAPI . '&' .
   'format=' . $multiFormat . '&' .
   'type=' . $multiType . '&' .
   'token=' . $multiToken;

$ch = curl_init($multiURL);
curl_setopt($ch, CURLOPT_URL, $multiURL);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $multiParams);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec($ch);
curl_close($ch);

// ----- This is for display purposes ----- //
echo '<pre>'.htmlspecialchars($data).'</pre>';
?>

If successful, response will contain details about your group or link:

<?xml version="1.0" encoding="utf-8"?>
<multiurl>
   <token>nF</token>
   <alias>yahooo</alias>
   <name>Yahoo</name>
   <link>http://www.yahoo.com</link>
   <clicks>3215</clicks>
</multiurl>