Login | Register Free (and benefit from useful features)
Create shorturls from any page of your site!

SHRINK THAT LINK!




Anzeige
API - arminize your (web) application!

Integrating arminizing functionality into your (web) application is super easy. Simply call arm.in handing over your link like this (NB: The URL must not be URL encoded as otherwise a bug in Apache’s mod_rewrite will f*ck up things badly):


http://arm.in/arminize/http://www.put-a-url-to-arminize-here.com

You will receive an xml-stream that looks like this, for example:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<url>
<arminized_url>http://arm.in/xyz</arminized_url>
<created>2009-01-19 16:44:29</created>
</url>

The tag <arminized_url> will contain your new short URL. In case something goes wrong, you will get this:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<url>
<error>INVALID_URL</error>
</url>

The <error> tag might contain: NO_URL, TOO_LONG_URL (if the URL is more than 2048 characters long), TOO_SHORT_URL (if the URL given is already shorter than the arminized one), INVALID_URL or - if something goes awfully wrong - FATAL_ERROR. That's it - there is nothing more to say!

Sample code in PHP using SimpleXML

Below is an easy yet fully working example of how to use the arminize api. The function arminize() simply expects the link you want to arminize and will return the short link or false if there was an error.

<?php
function arminize( $url )
{
$getXML = simplexml_load_file( "http://arm.in/arminize/" . $url );
if ( isset( $getXML->error ) )
{
switch ( $getXML->error )
{
case "TOO_SHORT_URL":
// handle error to your needs
case "TOO_LONG_URL":
// handle error to your needs
case "NO_URL":
// handle error to your needs
case "INVALID_URL":
// handle error to your needs
case "FATAL_ERROR":
// handle error to your needs
return false;
}
}
else
{
return $getXML->arminized_url;
}
}


// Simple test if everything works fine

$short_link = arminize( "http://www.bodalgo.com/index_english.php" );

if ( $short_link == false)
echo "Link could not be arminized!";
else
echo "Link was successfully arminized: " . $short_link;
?>