0

while implementing third party API it redirects me to my site with some details like token etc and my URL looks like this:

http://domain.com/index.php#access_token=access_token&red_url=test.com

But i am not able to get these parameters from url using $_GET or other method. in $_SERVER it show query_string as blank.

Any way to get all parameters from URL.

Many THanks, M.

Amit Kumar
  • 3,384
  • 6
  • 25
  • 42
  • 2
    depends how that's being populated. that `#access_token` should look like `?access_token` - Is that coming from JS/modal etc. `href="#"`? you need to post relevant code. – Funk Forty Niner Mar 11 '16 at 17:59
  • 1
    Fragment (part of URL after #) you can never get in PHP. Check e.g. here: http://stackoverflow.com/questions/2317508/get-fragment-value-after-hash-from-a-url-in-php – Miro Mar 11 '16 at 18:05

2 Answers2

0

Because of # in the URL you are getting blank in the S_GET or $_SERVER.

You can get it from Javascript like this:

var hash = window.location.hash;
0

The part of the url after the hash (#) is the fragment identifier:

Fragments depend on the document MIME type and are evaluated by the client (Web browser). Clients are not supposed to send URI-fragments to servers when they retrieve a document, and without help from a local application (see below) fragments do not participate in HTTP redirections

This is why you do not see these parameters in your server side code. You need to pass these parameters by javascript through another http call to the server as post or get parameters.

In javascript you can use location.hash to access the fragment identifier, but unless you use some js library, you need to parse its content yourself.

Shadow
  • 33,525
  • 10
  • 51
  • 64