php - Secure Browsing don't show different content for Fans/Non-Fans on a Facebook Page

104

I use the following Code on my Facebook page to check if user is FAN or NOT FAN. After this the users get different contents. It works fine but if I use Secure Browsing in Facebook I always see just: "You don't like this page yet."

I'm using the SSL-Proxy from my webhoster. Do you've any idea why it doesn't works while secure browsing?

<?php
require_once 'facebook-php-sdk/src/facebook.php';

// Create our Application instance.
$facebook = new Facebook(array(
  'appId' => 'X',
  'secret' => 'X',
  'cookie' => true,
));

$signed_request = $facebook->getSignedRequest();
$like_status = $signed_request["page"]["liked"];
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="https://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>zukundo</title>
<link rel="stylesheet" href="css/blueprint/screen.css" type="text/css" media="screen, projection">
</head>

<body>
<?php 
if ($like_status) {
    echo "You like this page.";
} else {
    echo "You like this page not yet.";
  }
?>

</body>
</html>
977

Answer

Solution:

I assume your application is a tab application, not a canvas one.

Here is how it works:

  • The facebook page will load your application in a iframe, with a POST parameter "signed_request" that contains an encrypted JSON Object, which is decrypted using your app secret.
  • This JSON object contains the info if the current user is fan or not of this page.

If you're using an SSL proxy, it's possible that this proxy is receiving the POST parameter, but not propagating it to your application afterward.

In this case, your app wouldn't be able to receive any info from facebook, so you wouldn't be able to know if the user is fan or not (at least, not until he has granted you the permission to access his data, so you could check using the API)

To fix that, you'll need to buy and install an SSL certificate for your domain. Godaddy.com seems to be the cheapest offer.

People are also looking for solutions to the problem: php - How can I make a facebook app work only on my page?

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.