views:

31

answers:

1

Hi guys, 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!

A: 

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);

RobertPitt
having a whitespace AFTER the closing ?> may also trigger this. It is recommended to leave out the closing PHP tag in scripts as much as possible to avoid this, and only keep the first line's opening tag.
Yanick Rochon
Perfect comment Yanick, This is one of the techniques you can use to avoid white-space and also save line counts, and large systems every line counts.
RobertPitt
Thanx guys, will give it a go and report back!
Any idea why I am getting a certificate error though?