Converter resultados do Ebay Link Generator em link bitly.com

Eu gerenciei um pequeno script PHP que pega o produto ebay pesquisado e o converte em promover o link ebay.

É assim: pesquisa do usuário por exemplo: ocz vertex
Clica em "Enviar" e obtém os resultados:

http://rover.ebay.com/rover/1/711-53200-19255-0/1?icep_ff3=10&pub=5575165347&toolid=10001&campid=5337851510&customid=&icep_uq=ocz vertex & icep_sellerId = & icep_ex_kw = & icep_sortBy = 15 & icep_catId = & icep_minPrice = & icep_maxPrice = & ipn = psmain & icep_vectorid = 229466 & kwid = 902099 & mtid = 824 & kw = lg

(Não é possível corrigir esse espaço no link gerado entre as palavras ocz e vértice)

Agora, o resultado é bom, mas eu quero abreviá-lo viabitly.com conta usandoa API deles.
Basicamente, eu quero que ele gere e converta os resultados completos do link do ebay em um pequeno link bitly.com (http://ebay.to/2scU91k por exemplo) e para ver esse link na minha conta bitly.

O processo é assim: o usuário procura por termos como ocz vertex -> clique em "Enviar" -> Obtenha o link curto ebay.to (enquanto o processo real está em segundo plano, converte para o endereço rover.ebay.com e depois para ebay . usando minhas credenciais bitly.com)

eu encontreieste eeste e especialmenteeste mas não entendi como implementar os resultados como um novo convertido em bits.

Aqui está o código PHP:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link rel="stylesheet" type="text/css" href="css/screen.css">
<style type="text/css">
    body{
        margin:0px;
        font-size:0.7em;
        font-family:trebuchet ms;
                            color:#222;
    }
    #mainContainer{
        width:840px;    
        margin:5px;
    }
    table,tr,td{
        vertical-align:top;
    }
    .textInput{
        width:300px;
    }
    html{
        margin:0px;
    }
    .formButton{
        width:75px;
    }
    textarea,input,select{
        font-family:helvetica;
    }
    i{
        font-size:0.9em;
    }



    </style>
<script language="Javascript">
<!--
var copytoclip=1
function HighlightAll(theField) {
var tempval=eval("document."+theField)
tempval.focus()
tempval.select()
if (document.all&&copytoclip==1){
therange=tempval.createTextRange()
therange.execCommand("Copy")
window.status="Contents highlighted and copied to clipboard!"
setTimeout("window.status=''",1800)
}
}
//-->
</script>


</head>
<table width="80%" height="100px" align="center" style="margin:0 auto"><tr><td align="center">
<h2>Link Generator Online</h2>
</td><tr></table>
<table width="80%" align="center" style="margin:0 auto"><tr><td align="center">
       </div>

 </td><td valign="top">
 <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<br>
URL<br>
<input type=text style="font-size: 13px; font-family: tahoma,arial; font-weight: bold; color: #000000; BORDER: #555 1px solid ; BACKGROUND-COLOR: #FFF" input name="url"  size="20">
<br>

<br>
<input type="SUBMIT" name="submit" VALUE="Submit"> 
</form>
</td></tr></table>
<?php
if(isset($_POST['submit'])){
$url = $_POST['url'];
$name=array($url);
foreach ($name as $name) 
{
if (ereg("^\.",$url)) {
echo "<br><center><font color=\"red\">Invalid Characters.</center>";  
 Die();
}
if (ereg("\<", $url)) {
echo "<br><center><font color=\"red\">Invalid Characters.</center>";  
 Die();
}
if (ereg("\[", $url)) {
echo "<br><center><font color=\"red\">Invalid Characters.</center>";  
 Die();
}
if (ereg("\'", $url)) {
echo "<br><center><font color=\"red\">Invalid Characters.</center>";  
 Die();
}
if (ereg("\#", $url)) {
echo "<br><center><font color=\"red\">Invalid Characters.</center>";  
 Die();
}
if (ereg("\`", $url)) {
echo "<br><center><font color=\"red\">Invalid Characters.</center>";  
 Die();
}

if (!strlen($url)) {
echo "<br><center><font color=\"red\">Empty Field.</center>";

Die();
}
if (strlen($url) > 100) {
echo "<br><center><font color=\"red\">The field cannot contain more than 150 characters.</center>";

 Die();
}
}
?>
<br>
<center>
<form name="vini">
<a class="highlighttext" href="javascript:HighlightAll('vini.select1')">Select All</a><br>
<textarea name="select1" rows=3 cols=75 style="font-family:tahoma;color:#555;border:1px dashed #ccc">
http://rover.ebay.com/rover/1/711-53200-19255-0/1?icep_ff3=10&pub=5575165347&toolid=10001&campid=5337851510&customid=&icep_uq=<?php echo $url ?>&icep_sellerId=&icep_ex_kw=&icep_sortBy=15&icep_catId=&icep_minPrice=&icep_maxPrice=&ipn=psmain&icep_vectorid=229466&kwid=902099&mtid=824&kw=lg
</textarea>
<br>
</form>

<?php
}
?>
</body>
</html>

Veja emviver: Gerador de link Ebay

questionAnswers(1)

yourAnswerToTheQuestion