Jump to content

Output URL shortened (Using Bit.ly) [Whats wrong with my code]


andre1990

Recommended Posts

I have an upload site whereby people get direct file links. I want to output links as bit.ly

 

My code stands as following:

 

<?php
$content = file_get_contents("http://api.bit.ly/v3/shorten?login=andre1990
&apiKey=R_56a95c84d089129012516e24806c3649
&longUrl='.urlencode($final).'&format=txt");
?>

//Input type because i want a text box with the link in it.

<input type="text" size="28" onClick=select() value="<?php echo $content; ?>" READONLY><p />

 

where $final is the uploaded file URL.

 

But it just outputs nothing, no bit.ly link.

 

Any help?

 

You are using the wrong quotes when entering the urlencode part of the string.

Change

file_get_contents("http://api.bit.ly/v3/shorten?login=andre1990
&apiKey=R_56a95c84d089129012516e24806c3649
&longUrl='.urlencode($final).'&format=txt")

to

file_get_contents("http://api.bit.ly/v3/shorten?login=andre1990
&apiKey=R_56a95c84d089129012516e24806c3649
&longUrl=".urlencode($final)."&format=txt")

Hi, thanks for the help, still blank though.

 

I currently have:

 

$final = $server."/".$destination."/".$name;

$contents = file_get_contents("http://api.bit.ly/v3/shorten?login=andre1990
&apiKey=R_56a95c84d089129012516e24806c3649
&longUrl=".urlencode($final)."&format=txt")

?>

 

Echoed out:

 

<input type="text" size="28" onClick=select() value="<?php echo $contents;?>" READONLY><p />

 

Struggling to see the issue.

You are missing a ; at the end of file_get_contents()

Is the URL in file_get_contents all on one line?

$content = file_get_contents("http://api.bit.ly/v3/shorten?login=andre1990&apiKey=R_56a95c84d089129012516e24806c3649&longUrl=".urlencode($final)."&format=txt");

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.