While building a facebook applicaiton that will be utilized across 100's of pages it was found a slight challenge to grab the current url dynamically...
First try:
function curPageURL() {
$pageURL = 'http';
if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";}
$pageURL .= "://";
if ($_SERVER["SERVER_PORT"] != "80") {
$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
} else {
$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
}
return $pageURL;
}
$currenturl = curPageURL();
A simple curl call was tried, however the server where the .php was was called not the facebook url
What worked:
<?php
$pageid = $_REQUEST['fb_sig_page_id'];
//grabs the current page id then use the current page id with the graph api
$jsonurl = file_get_contents("https://graph.facebook.com/" . $pageid);
$urlobj = json_decode($jsonurl);
$curUrl = $urlobj->{'link'};
print $curUrl;
?>
Hope this helps for anyone