Use the Graph API. Just ask:
https:
It should return you a JSON object that looks like this:
{ id: "<appid>", name: "<appname>", category: "<app category>", subcategory: "<app subcategory>", link: "<applink>", type: "application", }
So, to check if the specified app_id is really the application identifier, find the type property and check if it speaks the application. If the identifier is not found at all, it will simply return false.
Additional information: https://developers.facebook.com/docs/reference/api/application/
For instance:
<?php $app_id = 246554168145; $object = json_decode(file_get_contents('https://graph.facebook.com/'.$app_id));
source share