Common error messages
From Facebook Developer Wiki
How to turn on ALL error messages in PHP
You can enable error reporting on within your PHP scripts in a variety of manners. If you have access to PHP's php.ini configuration file, search for the directive error_reporting and set it to read:
error_reporting = E_ALL
This sets PHP's error reporting sensitivity to its maximum level.
If you're using a shared host in which access to the php.ini file is not an option, add one of the following commands to the top of your script to adjust PHP's error reporting level:
error_reporting(E_ALL);
ini_set('display_errors', 1);
How to show debug information for REST calls in PHP
Set the following anywhere before including facebook.php:
$GLOBALS['facebook_config']['debug']=true;
This sends output to the browser that lets you see the inputs and outputs to your REST calls.
WARNING: The Facebook downloadable library, as of 8/18/2007, has a couple of bugs that you can fix yourself by editing your copy of facebookapi_php5_restlib.php:
1. The output works only in Firefox but not IE. To make it work on both browsers, search for "toggleDisplay" in facebookapi_php5_restlib.php. Change the JavaScript block to the following:
<script type="text/javascript">
var types = ['params', 'xml', 'php', 'sxml'];
function toggleDisplay(id, type) {
for (var t in types) {
if (types[t] != type || document.getElementById(types[t] + id).style.display == 'block') {
document.getElementById(types[t] + id).style.display = 'none';
} else {
document.getElementById(types[t] + id).style.display = 'block';
}
}
return false;
}
</script>
2. This change is required regardless of what browser you use for testing: search for "print_r" in facebookapi_php5_restlib.php. Wrap all three occurrences of print_r inside calls to htmlspecialchars() so you can see angle brackets in your output:
print '<pre id="params'.$this->cur_id.'" style="display: none; overflow: auto;">'.htmlspecialchars(print_r($params, true)).'</pre>'; print '<pre id="xml'.$this->cur_id.'" style="display: none; overflow: auto;">'.htmlspecialchars($xml).'</pre>'; print '<pre id="php'.$this->cur_id.'" style="display: none; overflow: auto;">'.htmlspecialchars(print_r($result, true)).'</pre>'; print '<pre id="sxml'.$this->cur_id.'" style="display: none; overflow: auto;">'.htmlspecialchars(print_r($sxml, true)).'</pre>';
Session key invalid or no longer valid
You probably don't have a session - in PHP, this is resolved by adding this line to your code, at the beginning:
$facebook->require_login();
Note: If logging out and logging back in does not reset the session_key, there seems to be a bug in client/facebook.php. When the session key expires, the function fb_validate_params still calls the (expired) session key from cookies after checking POST and GET. Either advise your users to log out of facebook AND delete all cookies, or go into facebook.php and comment out the elseif that contains "get_valid_fb_params($_COOKIE..."
HTML tag not supported: "<script>" or HTML tag not supported: "<html>"
The most likely cause of this error is that your API and/or secret keys are incorrect, or you are referencing the wrong URL for your app somewhere. For more troubeshooting, view source of the error page - it is usually Facebook trying to do a script redirect or something, and you can tell by viewing the source rendered by Facebook.
There were 1 unclosed tags inside the body tag: p
First, check for any unclosed tags. If you can't find anything, check your links. If you have a link that ends in a directory (e.g. http://www.mysite.com/application instead of http://www.mysite.com/application/index.php) make sure to put a slash after the directory (so that it would become http://www.mysite.com/application/).
IE 7 Blocks Cookies from an iFrame
To get around this problem just use header('P3P: CP="CAO PSA OUR"'); at the top of your index.php file. See http://support.microsoft.com/kb/323752/EN-US/ for details.
Parse error: syntax error, unexpected '{' in appinclude.php on line 13
This is most likely a result of running a PHP5 file as PHP4. See solutions in the developer form: Specifying a file is PHP5, Using .htaccess.
From the readme:
NOTE: If you only have PHP4, we've built a modified version of the client library to work with that. Use the files inside the php4client directory instead of client. You'll need to download simplexml44 and extract it into the php4client/ directory to get it to work - you can get it at: http://downloads.sourceforge.net/ister4framework/simplexml44-0_4_4.tar.gz
On Using PHP4
For those using PHP4 you will also need to use PHP 4.3.0 or later and edit out the try statement in appinclude.php and "public" in facebookapi_php4_restlib.php.
appinclude on PHP4
How to translate this in PHP4??
.//catch the exception that gets thrown if the cookie has an invalid session_key in it
.try {
.if (!$facebook->api_client->users_isAppAdded()) {
. $facebook->redirect($facebook->get_add_url());
. }
.} catch (Exception $ex) {
. //this will clear cookies for your app and redirect them to a login prompt
. $facebook->set_user(null, null);
. $facebook->redirect($appcallbackurl);
.}
I tried
.//catch the exception that gets thrown if the cookie has an invalid session_key in it
. if (!$facebook->api_client->users_isAppAdded()) {
. $facebook->redirect($facebook->get_add_url());
. }
. else {
. //this will clear cookies for your app and redirect them to a login prompt
. $facebook->set_user(null, null);
. $facebook->redirect($appcallbackurl);
.}
but in developement, calling the callback url (index.php from tutorialapp) give at download:
<script type="text/javascript">
top.location.href = "http://www.facebook.com/login.php?v=1.0&api_key=md5&next=http%3A%2F%2Fahao.free.fr%2FFB%2Findex.php";
</script>
and redirect to http://www.facebook.com/home.php
(using phpMyAdmin - 2.11.3,MySQL: 5.0.51, both IE7 and firefox)
Facebook strips out IE filter: style
If you've ever tried to do this
.class {
filter:alpha(opacity=0);
}
you may have discovered that your presumed-transparent class has made a rather non-transparent appearance! Give it a sound thrashing, and then liberally apply backslashes:
.class {
filter:alpha\(opacity\=0\);
}
The backslashes fix seems to have stopped working :(
CSS: INTERNAL ERROR: incomplete url list
This occurs when you have css elements with background images. There's some weird behavior associated with this error. For instance:
<style type="text/css">
.class {
background-image:url(
);
}
.class2 {
background-image:url(
);
}
</style>
I forget what happens in this case - I think facebook strips out the urls and you end up with no background images. To solve that, you can do:
<style type="text/css">
.class {
background-image:url(
);
}
</style><style type="text/css">
.class2 {
background-image:url(
);
}
</style>
See [here]
furthermore, if you have this:
<style type="text/css">
.class {
text-decoration:blink;
}
[..other, non-background-imaged styles..]
</style>
[..bodacious content..]
<style type="text/css">
.class2 {
background-image:url(
);
}
</style>
[..more revolutionary content..]
<style type="text/css">
.class3 {
background-image:url(
);
}
</style>
In this case, .class2 will have a background-image of url(""), and .class3 will take on the background-image of .class2. If I had a .class4 with another background-image, it would take on the background-image of .class3.
So basically, if you want to have background-images on your css elements, you'll have to have no more or less than one background image per <style> block. Otherwise, you can't have any.
This will work:
<style type="text/css">
.class {
background-image:url("");
[..other styles..]
}
[..other styles..]
</style>
[..etc..]
<style type="text/css">
.class2 {
background-image:url(
);
}
[..other non-background declarations..]
</style>
[..etc..]
<style type="text/css">
.class3 {
background-image:url(
);
}
[..etc..]
</style>
xhtml link like this:
<style type="text/css">
.menu li a{
height:20px;
width:100px;
padding-top:3px;
display:block;
background-image:url(
);
background-repeat:no-repeat;
}
</style>
<style type="text/css">
.menu li a:link{
display:block;
background-image:url(
);
background-repeat:no-repeat;
}
</style>
<style type="text/css">
.menu a:visited {
display:block;
background-image:url(
);
background-repeat:no-repeat;
}
</style>
<style type="text/css">
.menu li a:hover{
display:block;
background-image:url(
);
background-repeat:no-repeat;
}
</style>
<div style="text-align:left;"> <ul class="menu"> <li><a href="index.php?action=default">Home</a></li> <li><a href="index.php?action=help">Help</a></li> </ul> </div>
