Client-side
The more obvious method is to use JavaScript, since your Web server has no awareness of the <frame>
itself. But unless you're accessing a frame whose parent frame is hosted on the same domain, the child cannot access (or manipulate) the parent frame. Allowing you to do so would violate JavaScript's same-origin policy.
If they're on the same domain, you can find the URL like so:
window.parent.location // Location object
window.parent.location.href // "http://..."
A similar question's answer recommends using document.referrer
to see whether the request is from Facebook; but that doesn't tell you the full URL. So it's not useful if you had multiple app IDs pointing to the same Facebook app. In that case, add a query string parameter to the Facebook Page Tab URL and base your app's content on that query string parameter.
Server-side (PHP)
For example, in Facebook, add a query string ?referrer=appid123
to the Page Tab URL. In PHP, you can check against the query string parameter like so:
if($_GET['referrer'] == 'appid123'){
// Do something for this visitor, who has come via my Facebook app
}