Debug Facebook API Requests

9 Jun, 2009  |  Written by Jon  |  under Facebook Development

Facebook has a great tool to debug API requests that is a bit tough to find / under documented. If you add the php code…

$GLOBALS['facebook_config']['debug']=true;

at the top of your page, and then make an api call to users->getinfo for example, then the debug tool outputs the following on your HTML page (inline, in a neat Ajax click to see details type box):

Params:

Array
(
    [uids] => 780432493
    [fields] => uid,first_name,last_name,name,locale,pic_square,profile_url
)

XML:

<?xml version="1.0" encoding="UTF-8"?>
<users_getInfo_response>
  <user>
    <uid>780432493</uid>
    <uid>780432493</uid>
    <first_name>Jon</first_name>
    <last_name>Pastor</last_name>
    <name>Jon Pastor</name>
    <locale>en_US</locale>
    <pic_square>http://profile.ak.facebook.com/v224/904/100/q780432493_3916.jpg</pic_square>
    <profile_url>http://www.facebook.com/profile.php?id=780432493</profile_url>
  </user>
</users_getInfo_response>

SXML:

SimpleXMLElement Object
(
    [@attributes] => Array
        (
            [list] => true
        )

    [user] => SimpleXMLElement Object
        (
            [uid] => Array
                (
                    [0] => 780432493
                    [1] => 780432493
                )

            [first_name] => Jon
            [last_name] => Pastor
            [name] => Jon Pastor
            [locale] => en_US
            [pic_square] => http://profile.ak.facebook.com/v224/904/100/q780432493_3916.jpg
            [profile_url] => http://www.facebook.com/profile.php?id=780432493
        )

)

PHP:

Array
(
    [0] => Array
        (
            [uid] => 780432493
            [first_name] => Jon
            [last_name] => Pastor
            [name] => Jon Pastor
            [locale] => en_US
            [pic_square] => http://profile.ak.facebook.com/v224/904/100/q780432493_3916.jpg
            [profile_url] => http://www.facebook.com/profile.php?id=780432493
        )

)

Very helpful for debugging to say the least!

Share:
  • email
  • Digg
  • Twitter
  • Facebook
  • del.icio.us
  • Mixx
  • MySpace
  • NewsVine
  • Reddit
  • StumbleUpon
  • Technorati
  • BlinkList
  • Google Bookmarks
  • LinkedIn
  • Live
  • Yahoo! Buzz
  • Fark
  • Netvibes
  • Netvouz
  • Propeller
  • Yahoo! Bookmarks

No Responses so far | Have Your Say!

Leave a Feedback

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>