andre1990 Posted September 27, 2011 Share Posted September 27, 2011 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? Link to comment https://forums.phpfreaks.com/topic/247921-output-url-shortened-using-bitly-whats-wrong-with-my-code/ Share on other sites More sharing options...
WebStyles Posted September 27, 2011 Share Posted September 27, 2011 where does $final come from? Link to comment https://forums.phpfreaks.com/topic/247921-output-url-shortened-using-bitly-whats-wrong-with-my-code/#findComment-1273052 Share on other sites More sharing options...
andre1990 Posted September 27, 2011 Author Share Posted September 27, 2011 $final is further above in the code, does it need to be in this bit of php tags too? Link to comment https://forums.phpfreaks.com/topic/247921-output-url-shortened-using-bitly-whats-wrong-with-my-code/#findComment-1273055 Share on other sites More sharing options...
Buddski Posted September 27, 2011 Share Posted September 27, 2011 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") Link to comment https://forums.phpfreaks.com/topic/247921-output-url-shortened-using-bitly-whats-wrong-with-my-code/#findComment-1273122 Share on other sites More sharing options...
andre1990 Posted September 27, 2011 Author Share Posted September 27, 2011 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. Link to comment https://forums.phpfreaks.com/topic/247921-output-url-shortened-using-bitly-whats-wrong-with-my-code/#findComment-1273136 Share on other sites More sharing options...
Buddski Posted September 27, 2011 Share Posted September 27, 2011 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"); Link to comment https://forums.phpfreaks.com/topic/247921-output-url-shortened-using-bitly-whats-wrong-with-my-code/#findComment-1273138 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.