简体   繁体   English

Facebook应用显示空白页

[英]Facebook app shows a blank page

Im trying to learn about creating applications for Facebook using PHP . 我试图学习有关使用PHP为Facebook创建应用程序的知识。 I created a simple hello world app,named myapp,using php. 我使用php创建了一个简单的hello world应用程序,名为myapp。 I have registered the app on facebook and also hosted the facebook php client client library on the server hosting my app. 我已经在Facebook上注册了该应用程序,并且还在托管我的应用程序的服务器上托管了facebook php客户端客户端库。 But when i go to http://apps.facebook.com/myapp/ , i get a blank page. 但是当我转到http://apps.facebook.com/myapp/时 ,我得到了一个空白页。 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 1)启用错误报告以了解实际情况

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

2) The api_key and app_secret values are strings, not integers. 2)api_key和app_secret值是字符串,而不是整数。

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

Don't you think you should output $friends ? 您不认为您应该输出$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. 我不确定API使用哪种格式,您可能需要遍历数组...但是,如果这对您没有任何意义,则在开始提取外部API之前,您可能需要学习一些编程知识。

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. Facebook由于某种原因看不到您的服务器,或者它崩溃了。 Stick an echo ( echo "testing"; ) right up at the top and see if you can see that on the output. 将回声( echo "testing"; )放在顶部,然后看是否可以在输出中看到。

If you can, there's something dark and twisty happening, RTMA or haggle with the Facebook gods on their dev forums. 如果可以的话,可能会发生一些黑暗而曲折的事情,RTMA或在其开发者论坛上与Facebook之神讨价还价。

If you can't, I'd wager facebook isn't actually accessing your site and there's something wrong in the application settings. 如果不能,我敢打赌Facebook实际上没有访问您的网站,并且应用程序设置中有问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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