1

i am developing facebook application, and i need to get the facebook root page url not iframe, all these methods: document.location,window.location and top.location... return the iframe url ( my hosting server ) not facebook url.

any suggestions ?

The Muffin Man
  • 19,585
  • 30
  • 119
  • 191
mokayyali
  • 153
  • 1
  • 4
  • 12
  • I would think that this is a security feature, and that you can't get the URL. – Boundless Dec 02 '11 at 00:42
  • This question is a duplicate of: http://stackoverflow.com/questions/5107451/how-to-get-the-top-url-from-a-facebook-application – N Rohler Dec 02 '11 at 04:37

1 Answers1

0

Try parent.location.href. It might not work if the iframe isn't coming from the same domain, and if so you will just need to get the request url referrer with your server code.

Edit: To get the current url in PHP try $_SERVER['HTTP_REFERER']

The Muffin Man
  • 19,585
  • 30
  • 119
  • 191
  • didn't work. application host in domain and of course facebook not in same domain. do you have any idea how to get it using php ? – mokayyali Dec 02 '11 at 00:50
  • Thank you :) and here is how to load php vars into flash as3 for reference: http://www.actionscript.org/forums/showpost.php3?p=1008997&postcount=6 – mokayyali Dec 02 '11 at 01:08
  • $_SERVER['PATH_INFO'] also get current iframe not parent page ( facebook url ) :S – mokayyali Dec 02 '11 at 02:20
  • 1
    `$_SERVER['HTTP_REFERER']`, not `$_SERVER['PATH_INFO']` – N Rohler Dec 02 '11 at 04:37
  • $_SERVER['HTTP_REFERER'] is worked like a charm :) Thanks a lot... its concatenate the facebook query strings to the iframe url `https://iframe_url?request_ids=196452310440879%2C184625744965192&ref=notif¬if_t=app_request` Thank you again – mokayyali Dec 02 '11 at 11:45