The following code was used to create a web app and get data from Facebook user using the Facebook php sdk.
require_once('facebook-php-sdk/src/facebook.php');
$facebook= new Facebook(array(
'appId' => $this->config->item('app_id'),
'secret' => $this->config->item('app_secret'),
'allowSignedRequest' => false,
));
$_REQUEST += $_GET;
$user = $facebook->getUser();
if ($user) {
try {
$user_profile = $facebook->api('/me?fields=picture.width(100).height(100),first_name,last_name,username,email');
} catch (FacebookApiException $e) {
$user = null;
}
} else {
$login_url = $facebook->getLoginUrl(array(
'scope' => 'publish_actions,email',
));
redirect($login_url, 'refresh');
}
This returned the data fine and worked great as a website. In my Facebook app Dashboard I created a website platform for this app. And as website it works great.
However I would like to use this as a Facebook canvas app.
I added a Facebook App platform in my dashboard. When I tried to add a page tab with this app on my Facebook page, I selected the app from "My Apps" and clicked use now, but the page comes up blank.
What Am I doing wrong. I also tried loading this in Woobox as a page tab, and again nothing showed up.
But when I go directly to the canvas url, it works fine.
What is happening here? Any help please.
Make sure you entered a secure canvas url in the platform settings. This can simply be the same canvas url with https:// rather than http://.