title: How to pass data from a facebook app to my server (via Ajax)?
body: <p><em>(Since FBML and FBJS are deprecated by Facebook, I cannot use those approaches to pass data to my server).</em></p>
  
  <p>I have an <strong>IFRAME facebook application</strong>, mainly built to be used by pages.</p>
  
  <p>When the page admin visits my application tab in their page, they see a settings page where they will be add information about their page. I have a submit button as well. Once the page admin submits information about his page, it will be sent to my server and it will be stored along with the page ID. Once this setup is done, when other users visits this application tab in the page, they will see the information posted by the page admin.</p>
  
  <p>I am using <strong>Facebook's PHP SDK</strong> in the server side to decode the signed request and get the page ID.</p>
  
  <p>The following is the code in my application's index.php to <strong>send data to my server</strong> <em>(along with the user input, page ID will also be passed, not shown here)</em></p>
  
  <pre><code>function sendData() {
      $.post('ajax.php', {
          data : $("#userdata").val()
      }, function(data) {
          alert(data);
      });
  }
  &lt;/script&gt;
  </code></pre>
  
  <p>The following is the simple ajax.php script. This is just a test script as of now.</p>
  
  <pre><code>&lt;?php
  echo "&lt;pre&gt;" . print_r($_POST) . "&lt;/pre&gt;";
  ?&gt;
  </code></pre>
  
  <p>The problem is only the user data is being sent to the server. There is a security problem in this approach. I want to send <strong>'signed_request'</strong> (that facebook sends initially to my index.php, using which I validate the request) along with the user data, so I can validate the request from the server side and update the information for the right page. Else, anyone can post a request like this and update the information for any page.</p>
  
  <p><img src="https://i.stack.imgur.com/bPI9S.png" alt="firebug image"></p>