0

I started programming a new Facebook App for my Webpage.
I own a valid HTTPS / SSL Cert for this App setted the configs. PHP and Apache is running.

The Problem:
When I try to run a simple Facebook php script, it shows me a blank page with no content. I uploaded for example the facebook example.php and it still shows a blank page when i open the page. The APP secret and APP ID is setted correctly.

Does anybody has an suggestion for me?

EDIT:

    <?php

require '/src/facebook.php';

$facebook = new Facebook(array(
  'appId'  => 'xxxx(appid)',
  'secret' => 'xxxx(secret)',
));

$user = $facebook->getUser();

if ($user) {
  try {
    $user_profile = $facebook->api('/me');
  } catch (FacebookApiException $e) {
    error_log($e);
    $user = null;
  }
}

if ($user) {
  $logoutUrl = $facebook->getLogoutUrl();
} else {
  $loginUrl = $facebook->getLoginUrl();
}

$naitik = $facebook->api('/naitik');

?>
<!doctype html>
<html xmlns:fb="http://www.facebook.com/2008/fbml">
  <head>
    <title>php-sdk</title>
    <style>
      body {
        font-family: 'Lucida Grande', Verdana, Arial, sans-serif;
      }
      h1 a {
        text-decoration: none;
        color: #3b5998;
      }
      h1 a:hover {
        text-decoration: underline;
      }
    </style>
  </head>
  <body>
    <h1>php-sdk</h1>

    <?php if ($user): ?>
      <a href="<?php echo $logoutUrl; ?>">Logout</a>
    <?php else: ?>
      <div>
        Login using OAuth 2.0 handled by the PHP SDK:
        <a href="<?php echo $loginUrl; ?>">Login with Facebook</a>
      </div>
    <?php endif ?>

    <h3>PHP Session</h3>
    <pre><?php print_r($_SESSION); ?></pre>

    <?php if ($user): ?>
      <h3>You</h3>
      <img src="https://graph.facebook.com/<?php echo $user; ?>/picture">

      <h3>Your User Object (/me)</h3>
      <pre><?php print_r($user_profile); ?></pre>
    <?php else: ?>
      <strong><em>You are not Connected.</em></strong>
    <?php endif ?>

    <h3>Public profile of Naitik</h3>
    <img src="https://graph.facebook.com/naitik/picture">
    <?php echo $naitik['name']; ?>
  </body>
</html>

This Code is from https://github.com/facebook. Its the example.php which isn't working.

royhowie
  • 11,075
  • 14
  • 50
  • 67

2 Answers2

1

This example should show you Naitik's picture regardless of whether you set the app_id or app_secret correctly. If it doesn't, it means that your example.php file was not setup correctly or there's something wrong with your server.

What is the PHP error you get when you load the page?

-- EDIT --

Refer to this post for the solution: OAuth Error: This IP can't make requests for that application

Community
  • 1
  • 1
jyek
  • 1,081
  • 9
  • 19
  • There is no error when i load the page. It is just Blank, no source code etc... I think the installation of facebook php sdk was wrong, but i cant find out why. I tried phpinfo and it shows up that apache & php is working. Just if i use facebook php there happens nothing. – Marcel la Bomba Apr 08 '13 at 09:24
  • Thanks RaaRaaRaa, i tried the javascript sdk in the example folder and it is working. Example.php is still giving me a blank page. Maybe there is something wrong with the server. Anybody else got an idea? – Marcel la Bomba Apr 08 '13 at 09:33
  • @Marcel la Bomba Is your link to facebook.php correct? Try: "require( dirname(__FILE__) . '/src/facebook.php' );" Also, your php should be able to display error messages if there is an error: http://stackoverflow.com/questions/5680831/php-does-not-display-error-messages – jyek Apr 08 '13 at 10:24
  • Thanks that helped me out a bit. The Error is the following: Fatal error: Uncaught OAuthException: This IP can't make requests for that application. thrown in /var/www/vhosts/xxx.de/httpdocs/src/base_facebook.php on line 1254 – Marcel la Bomba Apr 08 '13 at 14:41
  • @Marcel la Bomba Edited my answer...see above – jyek Apr 08 '13 at 14:53
1

Maybe your mobile solution is out of your facebook app's allowed domain/subdomain? By that I mean, perhaps you set your app domain as "something.com" but you're trying to invoke the login url from "mobile.something.com", that would be a valid reason to display a blank page.

Andres SK
  • 10,779
  • 25
  • 90
  • 152