This question already has an answer here:
Get Facebook Page Tab ID of current Tab?
Facebook sends a POST variable called "signed_request" to your iframe, you can read and encode it but the easiest way is to use the PHP SDK. It offers a function called "getSignedRequest": https://developers.facebook.com/docs/reference/php/facebook-getSignedRequest
The fields include a page object with the ID: https://developers.facebook.com/docs/reference/login/signed-request
If you don't want to use the PHP SDK, here is an example how to encode signed_request: https://developers.facebook.com/docs/facebook-login/using-login-with-games