Common error messages

From Facebook Developers Wiki

Jump to: navigation, search

Contents

[edit] How to turn on ALL error messages in PHP

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

[edit] 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>';

[edit] 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();

[edit] 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.

[edit] 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/).

[edit] 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.

[edit] Invalid parameter

I get error 100 "invalid parameter" on a call to facebook.auth.getSession with the Java client library.
The documentation for the method says: One of the parameters specified was missing or invalid.
But the POST URL from the debug output looks valid to me:

facebook.auth.getSession POST: http://api.facebook.com/restserver.php/v=1.0&method=facebook.auth.getSession&auth_token=<auth_token>&api_key=<api_key>&sig=<sig>

(I removed the values for auth_token, api_key and sig) 

Is the order of elements important? This is just as created by the ExampleClient provided with the Java client library.
The previous call to facebook.auth.createToken works fine.

We don't expect a question here, but an answer. Thanks to post any.

[edit] 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)

[edit] Warning: simplexml_load_string() [function.simplexml-load-string]: Entity: line 2: parser error :

unsure what is causing this. seems to be an error with running FQL queries. . . any thoughts?

[edit] 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 :(

[edit] 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(some.png);
 }
 .class2 {
   background-image:url(some_other.png);
 }
 </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(some.png);
 }
 </style><style type="text/css">
.class2 {
   background-image:url(some_other.png);
 }
 </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(some.png);
 }
 </style>
 [..more revolutionary content..]
 <style type="text/css">
 .class3 {
   background-image:url(some_other.png);
 }
 </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(some.png);
 }
 [..other non-background declarations..]
 </style>
 [..etc..]
 <style type="text/css">
 .class3 {
   background-image:url(some_other.png);
 }
 [..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(link.gif);
 	background-repeat:no-repeat;
 }
 </style>
 <style type="text/css">
 .menu li a:link{
 	display:block;
 	background-image:url(link.gif);
 	background-repeat:no-repeat;
 }
 </style>
 <style type="text/css">
 .menu a:visited {
 	display:block;
 	background-image:url(link.gif);
 	background-repeat:no-repeat;
 }
 </style>
 <style type="text/css">
 .menu li a:hover{
 	display:block;
 	background-image:url(hover.gif);
 	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>