views:

62

answers:

1

In my Wordpress Blog I'm currently using an integrated http://U.nu url-shortener.

For this I've got in functions.php

function getunuUrl($url) {
    $unuurl = file_get_contents("http://u.nu/unu-api-simple?url=".$url);
    return $unuurl;
}

and in my post.php

<?php $uurl = getunuUrl(get_permalink($post->ID)); 
echo '<a href="'.$uurl.'">Short Url</a>' ?>

I can't find a way to integrate j.mp the same way. Anyone able to help me out?

A: 

Looks like j.mp is a mirror of bit.ly
According to bitly API:

http://api.bit.ly/shorten?version=2.0.1&longUrl=http://cnn.com&login=bitlyapidemo&apiKey=R_0da49e0a9118ff35f52f629d2d71bf07

I shoul change function getunuUrl (or add a new one):

function getunuUrl($url) {
    $unuurl = file_get_contents("http://api.bit.ly/shorten?version=2.0.1&longUrl=".$url."&login=bitlyapidemo&apiKey=R_0da49e0a9118ff35f52f629d2d71bf07");
    return $unuurl;
}

Don't forget to change login & apiKey to your own.

Dmitriy
Aww, forget it then. I'm not gonna get an account when I can have one for free at U.nu. Thanks though! Appreciate it!
NoCanDo