Download & Extend

App breaks out of iframe after FB Connect redirect

Project:Drupal for Facebook
Version:7.x-3.x-dev
Component:Canvas Pages (iframe)
Category:support request
Priority:normal
Assigned:Unassigned
Status:active

Issue Summary

After user connects with FB, and local user account creation is enabled the user is taken to the site, and breaks out of the iframe.

For an example check http://apps.facebook.com/dupeoff

Comments

#1

Using: 7.x-3.3-beta4 Ihad no iframe break
but
After upgrading latest dev, my iframe breaks

This is my code

$block = module_invoke('fb_connect', 'block_view', SOCIAL_HANDS_LOGIN_BLOCK);
return '<div class="'.$class.'">'.render($block['content']).'<div class="descrip"><h3>'.$descrip.'<h3></div></div>';

Please help, I cannot upgrade

#2

Component:Facebook Connect» Canvas Pages (iframe)
Category:bug report» support request
Status:active» postponed (maintainer needs more info)

Links on a canvas page can go anywhere, so it's not a bug that some links go to an external website. In many cases, that's done on purpose.

The trick is how the links are produced in drupal. By default links made with l() or url() calls will stay on the canvas page. But there's no guarantee with module how they are building their links. So if you have a specific link going away from the canvas page, you should determine what module is making it. Drupal core links, ie. menu items, should work.

Also there's caching. If your drupal is serving both canvas pages and also regular pages, drupal may cache a block intended for one and display it on the other. That's a little trickier to customize but if you disable caching you can at least determine if that is the cause.

#3

Many thanks,

i need some more help,

My function is called by:

  $items['orca/publish'] = array(
    'page callback' => 'orca_social_fb_publish_prepare',
    'theme callback'=> 'fb_nc_publish_reactions_theme',   
    'access callback' => TRUE,
    'type' => MENU_CALLBACK,
    'file' => 'orca_social.actions.inc',
    'file path' => drupal_get_path('module', 'fb_nc_publish'),   
  );

and the function is:

function orca_social_fb_publish_prepare($client, $mode, $nid=FALSE, $url=FALSE){
if (!$fbuser = orca_social_get_fb_user()) {
$descrip = "";
$class = "comentar";
switch ($mode){
case 'post':
$descrip = 'Conecta con Facebook para Publicar';
$class .= ' facebookblock';
break;
case 'comment':
$descrip = 'Conecta con Facebook para Comentar';
break;
case 'sync':
$descrip = 'Conecta con Facebook para Sincronizar';
break;
case 'share':
$descrip = 'Conecta con Facebook para Compartir';
break;
}

$block = module_invoke('fb_connect', 'block_view', SOCIAL_HANDS_LOGIN_BLOCK);
    return '<div class="'.$class.'">'.render($block['content']).'<div class="descrip"><h3>'.$descrip.'<h3></div></div>';
}
...

Can you suggest my something??
Thanks I am quite lost

#4

Same hear. the breat is produced after user has autorized the app. it breaks the iframe and redirect you to my home page without the iframes but correctly logged.

P.s. Could it be related to this piece of code on settings file?

<?php
// @TODO - somehow detect whether a signed request indicates canvas page or not.
// fb_settings(FB_SETTINGS_TYPE, FB_SETTINGS_TYPE_CANVAS);
?>

That line is it commented. all my calls to fb_is_canvas are returning false even if, i think, they should return true.

#5

Status:postponed (maintainer needs more info)» active

Changed the status, correct me if i am wrong

#6

I guess I missed it the first time around. You are saying that normal links work as expected, but the connect button is what breaks user out of canvas page? Please let me know if that is correct.

If this problem is not limited to just the connect button, please paste here what you've added to your settings.php. I.e. are you including fb_url_rewrite?

#7

For me, it only happens with the connect button, once connected I have a form and it works well inside the iframe.
I did not upgrade and using 7.x-3.3-beta4 because with this version the connect doesn´t break iframe.
Here are the last lines of setting.php

if (!is_array($conf))
  $conf = array();

$conf['fb_verbose'] = TRUE; // debug output
//$conf['fb_verbose'] = 'extreme'; // for verbosity fetishists.

// More efficient connect session discovery.
// Required if supporting one connect app and different canvas apps.
$conf['fb_id'] = '116195288419253'; // Your connect app's ID goes here.

// Enable URL rewriting (for canvas page apps).
include "sites/all/modules/fb/fb_url_rewrite.inc";
include "sites/all/modules/fb/fb_settings.inc";

// Header so that IE will accept cookies on canvas pages.
//if (!headers_sent()) {
//  header('P3P: CP="We do not have a P3P policy."');
//}
// end of settings.php
header('P3P: CP="CAO PSA OUR"');
header('Access-Control-Allow-Origin: *');

Thanks

#8

Exactly that, Dave. Links in my app works perfectly inside canvas. This undesired redirect only happens once the user authorize the facebook app.

User is prompted for facebook permissions, and once the user accept them, he is redirect to the url but outside the facebook canvas page.

Didn't try with the latest beta though. Let me check

#9

Tested with last beta, but same behaviour.

#10

I'm having trouble reproducing this.

Are you each using the fb_connect.module block? Have you changed it's default configuration in any way?

When prompted to log into facebook, your browser should show you a long URL, something starting with "https://www.facebook.com/login.php?api_key=". Can you paste the entire URL here? It should have a next=... parameter which controls where the user is ultimately sent.

#11

sorry. problem is not in login. it's inmediately after authorizing the app. that's it, on first access. anyway, i will try to dig into that url params.

nobody click here