4

I want to fetch the current URL which I've received as a callback during authorization from Salesforce.com. The data in the url is in the fragments portion.

halfer
  • 19,824
  • 17
  • 99
  • 186
Himanshu
  • 1,433
  • 4
  • 24
  • 35
  • 9
    The fragment is not transmitted to the server; it’s for client use only. – Gumbo Nov 22 '10 at 13:40
  • 1
    possible duplicate of [PHP & Hash / Fragment Portion of URL](http://stackoverflow.com/questions/1162008/php-hash-fragment-portion-of-url) and a [couple more](http://stackoverflow.com/search?q=fragment+php). Please heed [http://stackoverflow.com/questions/ask-advice](http://stackoverflow.com/questions/ask-advice) – Gordon Nov 22 '10 at 13:41

3 Answers3

0

You can use a combination of $_SERVER['HTTP_HOST'] and $_SERVER['REQUEST_URI'] but HTTP_HOST is not very reliable so try defining URL's for known sources and appending the request uri to the end.

define('URI', 'http://Salesforce.com');
echo URI. $_SERVER['REQUEST_URI'];

You will not be able to get the fragment portion of the URI back as it is used on the client only. If you need this you will manually have to send them to a server with some JavaScript.

-1

With the $_SERVER variable, you could do this:

echo $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];

Take a look at the following page for all available keys: php.net

Cpt. eMco
  • 565
  • 4
  • 13
  • Its not working. With this I am not able to get the complete URL. https://localhost/sf/oauth_callback.php#access_token=00DO00000004s15!ARIAQC3mpf.jfzgrOmhCQYXS.K9JcN2PPVGCHA3xU4LBA_SPpHQcawtTSmthLFDLhM4iMTeJXMZPkN_x5dSKPcJZbgPypXeG, using dese functions am getting the value till sf/oauth_callback.php only, I want the fragment parts to be included in it. – Himanshu Nov 22 '10 at 13:48
-3

I belive its something like $_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'].$_SERVER['QUERY_STRING'];

http://php.net/manual/en/reserved.variables.server.php

Nir
  • 24,619
  • 25
  • 81
  • 117