iframe重定向错误

I have a facebook iframe application that is having trouble redirecting, I keep getting security certificate errors like these "Content was blocked because it was not signed by a valid security certificate.", here is the redirect code,

$params = array(
    'canvas'=>1,
    'fbconnect'=>0,
    'req_perms'=>'user_photos,publish_stream,offline_access',
    'next'=>'http://apps.facebook.com/my-test/', 
    'cancel_url'=>'http://apps.facebook.com/my-test/',
);

$redirect = $facebook->getLoginUrl($params);

echo "<script language='Javascript' type='text/javascript'>top.location.href='$redirect';</script>";

and when I try to redirect the user using a PHP redirect, like so,

header('Location: '.$redirect);

all I get is a iframe filled with a black background.

Is there another way I could redirect the page? or fix this error?

Thanx in advance!

Make sure your not sending whitespace in your scripts before the header command.

An example of whitespace

<?php
echo ' ';

header('Location: home'); //Will not send.
?>

Another example:

     <-- Whitespace here maybe?
<?php
    header('Location: home'); //Will not send.
?>

Try turn on php errors to debug whats going on when you send the header command, using error_reporting(E_ALL);