PHP header() redirect not working after shortening URL using bit.ly
Posted
by Fabian Kreiser
on Stack Overflow
See other posts from Stack Overflow
or by Fabian Kreiser
Published on 2010-04-21T17:44:07Z
Indexed on
2010/04/22
12:13 UTC
Read the original article
Hit count: 172
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
© Stack Overflow or respective owner