Reputation: 783
I'm working on a Facebook app that I'd like to use as a page tab. The idea is that it would display different content based on the Facebook Page the tab is used on.
<?php require_once ("php-sdk/facebook.php");
$config = array();
$config['appId'] = 'xxxxx';
$config['secret'] = 'xxxxx';
$facebook = new Facebook($config);
$signed_request = $facebook->getSignedRequest();
$page_id = $signed_request["page"]["id"]; ?>
Unfortunately, it only occasionally works. Right now, I'm simply trying to echo out the $page_id, and it doesn't always work. Sometimes it will correctly echo out the $page_id, other times it echoes out a null value.
Any ideas?
Upvotes: 3
Views: 2618
Reputation: 1
i had the same problem, after hours surfing the internet i found out the problem was with my app secret ID
i hope this helped
Upvotes: 0
Reputation: 11
I was geting the same problem with facebook tab app on heroku, the problem was at the sample code index.php
if (substr(AppInfo::getUrl(), 0, 8) != 'https://' && $_SERVER['REMOTE_ADDR'] != '127.0.0.1') {
header('Location: https://'. $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']); exit();
The redirection was making page info array to desapear. Without this everything works :)
Upvotes: 1
Reputation: 783
I finally figured this out. There is nothing wrong with my code. The problem was on the server. It was set to change all http traffic to https traffic. So, the tab was pulling the page_id for individuals who set up Facebook to use https. It wasn't able to pull in the page_id if someone was viewing facebook using http.
It's all fixed now. The server allows http traffic to stay http and https traffic to stay https.
Upvotes: 4