PHP header() redirect not working after shortening URL using bit.ly
- by Fabian Kreiser
Hi, I have a problem with php header redirect. I already spent hours trying to fix it.
The problem doesn't occur when the bit.ly api is not used in the script, I have no clue why.
<?php
if (strlen($_GET['url']) > 26) {
$shortenedURL = $_GET['url'];
if (isset($_GET['login']) && isset($_GET['apikey'])) {
$shortenedURL = file_get_contents('http://api.bit.ly/v3/shorten?format=txt&login='.urlencode($_GET['login']).'&apiKey='.$_GET['apikey'].'&uri='.urlencode($_GET['url']));
}
else {
$shortenedURL = file_get_contents('http://icbrd.net/shorten.php?longurl='.$_GET['url']);
}
if (strlen($shortenedURL) > 0) {
header( 'Location: icebird://compose?status='.$shortenedURL.'%20' );
exit();
}
else {
header( 'Location: icebird://compose?status='.$_GET['url'].'%20' );
exit();
}
}
else {
header( 'Location: icebird://compose?status='.$_GET['url'].'%20' );
exit();
}
?>
I hope you can help me, as this is driving me crazy.
Regards