WHOAAAAAAAAAAAAAAAAAAA! That is some really fucked up code. Use this instead:
PHP Code: 
<?php

$username 
"";
$password "";
$link "";

//STOP, U NO EDIT BELOW!
$link trim($link);
$id explode('/'$link);
$id trim($id[4]);

$page file_get_contents("http://api.filesonic.com/link?method=getDownloadLink&u=$username&p=$password&ids=$id&format=json");
$page json_decode($pageTRUE);

$finallink trim($page['FSApi_Link']['getDownloadLink']['response']['links'][$id]['url']);

echo 
$finallink;

//PROFIT!
?>