简体   繁体   中英

Facebook app shows a blank page

Im trying to learn about creating applications for Facebook using PHP . I created a simple hello world app,named myapp,using php. I have registered the app on facebook and also hosted the facebook php client client library on the server hosting my app. But when i go to http://apps.facebook.com/myapp/ , i get a blank page. Any way to fix this ? Below is the code :

<?php
require_once('./facebook/php/facebook.php');

/* initialize the facebook API with your application API Key
  and Secret */
$facebook = new Facebook(1a3c459414c9cacad4b250af86092412,6253dc1b7573dc870b97838d9f3bf39a);


$fb_user = $facebook->require_login();


?>

Hello <fb:name uid='<?php echo $fb_user; ?>' useyou='false' possessive='true' />! Welcome to my first application!

<?php


echo "<pre>Debug:" . print_r($facebook,true) . "</pre>";

?>

Thank You.

Two things that jump out at me

1) Enable error reporting to get a handle on what's really happening

ini_set( 'display_errors', 1 );
error_reporting( E_ALL );

2) The api_key and app_secret values are strings, not integers.

$facebook = new Facebook("1a3c459414c9cacad4b250af86092412","6253dc1b7573dc870b97838d9f3bf39a");

Don't you think you should output $friends ?

Just something like:

$friends = $facebook->api_client->friends_get();
echo $friends;

I'm not sure what format the API uses, you might need to cycle through the array... but if that means nothing to you, you might need to learn some programming before you start pulling external APIs.

Edit: If you're actually getting a blank page, ignore above. Facebook can't see your server for some reason, or it's crashing out. Stick an echo ( echo "testing"; ) right up at the top and see if you can see that on the output.

If you can, there's something dark and twisty happening, RTMA or haggle with the Facebook gods on their dev forums.

If you can't, I'd wager facebook isn't actually accessing your site and there's something wrong in the application settings.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM