title: Facebook FB.api( '/me' ) throwing: "TypeEror: 'undefined' is not an object"
body: <p>Facebook's <code>FB.api( '/me' )</code> function recently started throwing the following error <strong>when run in mobile Safari</strong>:</p>
  
  <blockquote>
    <p>TypeEror: 'undefined' is not an object</p>
  </blockquote>
  
  <p>The code <strong>works fine in a desktop browser</strong> (tested in Chrome 19dev/OS X and Safari 5.1.3/OS X). I have tried two different Facebook app IDs on two different domains with the same results. I have tried two different Facebook user IDs with the same results. I have tried authenticating with <code>FB.login()</code> and <code>FB.getLoginStatus()</code> and it made no difference. </p>
  
  <p>Demo: <a href="http://thinkingstiff.com/fb.htm" rel="nofollow">http://thinkingstiff.com/fb.htm</a></p>
  
  <p>Script:</p>
  
  <pre class="lang-js prettyprint-override"><code>window.onload = function () {
  
      var script = document.createElement( 'script' );
      script.async = true;
      script.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
      document.getElementById( 'fb-root' ).appendChild( script );
  
      window.fbAsyncInit = function () {
          FB.init( {
              appId: '252706924818818',
              cookie: true,
              status: true,
              xfbml: true,
              oauth: true
          } );
      };
  
      function login1() {
          FB.login( function ( response ) {
              if ( response.authResponse ) {
                  try {
                      FB.api( '/me', function ( response ) { // this line throws error
                          alert( 'success: ' + response.name );
                      } );
                  } catch ( error ) {
                      alert( 'error: ' + error );
                  };
              } else {
                  alert( 'unauthorized' );
              };
          }, { scope: 'email' } );
      };
  
      function login2() {
          FB.getLoginStatus( function ( response ) {
              if ( response.authResponse ) {
                  try {
                      FB.api( '/me', function ( response ) { // this line throws error
                          alert( 'success: ' + response.name );
                      } );
                  } catch ( error ) {
                      alert( 'error: ' + error );
                  };
              } else {
                  alert( 'unauthorized' );
              };
          } );
      };
  
      function initialize() {
          document.getElementById( 'login1' ).addEventListener( 'click', login1, false );
          document.getElementById( 'login2' ).addEventListener( 'click', login2, false );
      };
  
      initialize();
  
  };
  ​
  </code></pre>
  
  <p>HTML:</p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;button id="login1" class="fb-button"&gt;Login 1&lt;/button&gt;
  &lt;button id="login2" class="fb-button"&gt;Login 2&lt;/button&gt;
  &lt;div id="fb-root"&gt;&lt;/div&gt;
  </code></pre>