title: How do I use FB.api?
body: <p>I have a small application. As the page loads it displays me 'Undefined'. Why is that and how do I sort this out?</p>
  
  <pre><code>&lt;html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml"&gt;
      &lt;head&gt;
         &lt;title&gt;Facebook Stream Publish PHP example&lt;/title&gt;
  
          &lt;script src="//connect.facebook.net/en_US/all.js"&gt;&lt;/script&gt;
      &lt;/head&gt;
      &lt;body&gt;&lt;div id="fb_root"&gt;&lt;/div&gt;
  
         &lt;script type="text/javascript"&gt;
              FB.init({appId: 'appid', status: true, cookie: true, xfbml: true});
              var body = 'Reading JS SDK documentation';
              FB.api('/me', 'post', { message: body }, function(response) {alert(response.length);
                if (!response || response.error) {
                  alert('Error occured '+response.error+"  "+response);
                } else {
                  alert('Post ID: ' + response.id);
                }
              });
  
         &lt;/script&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>