vrypan — panayotis vryonis
My blog is a digital scrapbook of ideas, thoughts and personal events. My home is vrypan.net.
Home — Archive: All · English · Greek — RSS Feeds: full feed · other options
#api #php #urlborg #urlborg #en

using urlB.org API from PHP

If you are interested to use the urlB.org API from within PHP, here is a simple wrapper.

First download urlborg.php (and, of course, make sure you have your API key).

Now, creating short URLs and getting info about them is easy. Here is an example:

require_once 'urlborg.php' ;
$ub = new urlBorg('use your API key here') ;
$info = $ub->get_info('lgfy') ;
if ($ub->get_error()) { 
   echo '
ERROR! Code:' . $ub->get_error('n') . ' desc:' . $ub->get_error('s') ; } else { print_r($info) ; } $short = $ub->create_new('http://vrypan.net/') ; if ($ub->get_error()) { echo '
ERROR! Code:' . $ub->get_error('n') . ' desc:' . $ub->get_error('s') ; } else { print_r($short) ; }

(the example is included in the class headers. Don't copy-paste it from this post since Wordpress seems to change the quotes in ways that PHP doesn't like :-)

Share this post:
The Letter is a newsletter I send out whenever I have something to say or share. It may take a few days, weeks or months for the next one.
Privacy: I hate spam as much as you do, maybe more. I will not share your email with advertisers, etc.