title: Retrieve the number of messages send
body: <p>In facebook js sdk app development..I need to find the number of facebook messages send from the inbox. The code which I am using is</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;meta charset="UTF-8"&gt;
  &lt;/head&gt;
     &lt;body&gt;
  
  &lt;script&gt;
  
    function statusChangeCallback(response) {
  console.log('statusChangeCallback');
  console.log(response);
  
  if (response.status === 'connected') {
    // Logged into your app and Facebook.
    testAPI();
  } else if (response.status === 'not_authorized') {
    // The person is logged into Facebook, but not your app.
    document.getElementById('status').innerHTML = 'Please log ' +
      'into this app.';
  } else {
    // The person is not logged into Facebook, so we're not sure if
    // they are logged into this app or not.
    document.getElementById('status').innerHTML = 'Please log ' +
      'into Facebook.';
  }
  
  
  }
  
  
  
    function checkLoginState() {
  FB.getLoginStatus(function(response) {
    statusChangeCallback(response);
      });
  }
  
    window.fbAsyncInit = function() {
    FB.init({
  appId      : '289533237896176',
  cookie     : true,  // enable cookies to allow the server to access 
                      // the session
  xfbml      : true,  // parse social plugins on this page
  version    : 'v2.0' // use version 2.0
    });
  
    };
  
  
    (function(d, s, id) {
      var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) return;
  js = d.createElement(s); js.id = id;
  js.src = "//connect.facebook.net/en_US/sdk.js";
  fjs.parentNode.insertBefore(js, fjs);
    }(document, 'script', 'facebook-jssdk'));
  
  
    function testAPI() {
  console.log('Welcome!  Fetching your information.... ');
  FB.api('/me/inbox',function(response) {  for (var i=0;i&lt;response.data.length;i++) {
  var thread = response.data[i];
  
  for (var j=0;j&lt;thread.comments.data.length;j++) {
      var comment = thread.comments.data[j].message;
  
      console.log(comment);
  
  
  }
  }
  
  
  
  }
  
  
  
  );
  
  
  }
  
  &lt;/script&gt;
  
  &lt;fb:login-button scope="public_profile,email,read_mailbox" onlogin="checkLoginState();"&gt;
  </code></pre>
  
  <p></p>
  
  <pre><code>&lt;div id="status"&gt;
  
  &lt;div id="fb-root"&gt;&lt;/div&gt;
  
  &lt;/div&gt;
  
  &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>
  
  <p>This script successfully retrieves the  number of first 10 messages ..what I need is to display the number of messages in total ..</p>