API
API of short URL service RLU.ru is very simple. You need to make a GET-request in order to use it:
http://rlu.ru/index.sema?a=api&del=10&preview=1&link=http%3A%2F%2Fgoogle.com
The request parameters mean the following:
- a=api — the reserved parameter, can not be changed.
- del=10 — when short URL must be deleted. If permanent link is required, this parameter should be skipped or should be indicated as del=0. Possible values are from 0 to 720. Short URL will be deleted in 10 hours in this case.
- preview=1 — allows you to get short URL to the page, where long URL can be reviewed first and then you can go either to the indicated link. If parameter isnt set or preview=0 you will receive direct short URL without preview page.
- link=http%3A%2F%2Fgoogle.com — transmits a long link address. This is an example how http://google.com address can be transmitted.
Required parameters which must be in every request: a=api and link=[long URL].
If you send correct request, you receive short URL like:
http://rlu.ru/1a2b3
If you send wrong request (for example, long URL is missing), you receive the error description (in UTF8 encoding). It always starts with «Error». For example:
Error: Long URL is incorrect.
PHP example:
<?php
$res=file_get_contents('http://rlu.ru/index.sema?a=api&link='.urlencode('http://google.com'));
$pos=strpos($res,'Error: ');
if ($res=='' || $pos!==false && $pos==0) echo 'The error is occurred. '.$res;
else echo 'Short URL: '.$res;
?>
$res=file_get_contents('http://rlu.ru/index.sema?a=api&link='.urlencode('http://google.com'));
$pos=strpos($res,'Error: ');
if ($res=='' || $pos!==false && $pos==0) echo 'The error is occurred. '.$res;
else echo 'Short URL: '.$res;
?>
Perl example:
#!/usr/bin/perl
use LWP::UserAgent;
use URI::Escape
my $ua = LWP::UserAgent->new;
my $response=$ua->get('http://rlu.ru/index.sema?a=api&link='.uri_escape('http://google.com'));
my $res=$response->content;
if ($res eq '' || $res=~/^Error: /) { print 'The error is occurred. '.$res; }
else { print 'Short URL: '.$res; }
use LWP::UserAgent;
use URI::Escape
my $ua = LWP::UserAgent->new;
my $response=$ua->get('http://rlu.ru/index.sema?a=api&link='.uri_escape('http://google.com'));
my $res=$response->content;
if ($res eq '' || $res=~/^Error: /) { print 'The error is occurred. '.$res; }
else { print 'Short URL: '.$res; }
Attention! If you send a lot of requests from one IP, it can be blocked. If you plan to add more then 100 URLs in one hour, please let the technical support know. Otherwise your IP can be blocked unexpectedly. Prior added URLs can be deleted.