Getting a PHP Parameter when it's # instead of?

Hello! My name is Donovan and I’m learning PHP. I’m using the Yandex OAuth API to check if they have an email at @mail.(my domain) through Yandex360.

The problem: I need to extract the token from this URL in PHP.
https://mail.(my domain)/auth/server.php#access_token=TOKENGOESHERE&token_type=TYPE&expires_in=EXPIRATION
I want to get TOKENGOESHERE from the URL in PHP to connect to the Yandex API to check the email on the account. How can I get TOKENGOESHERE from the URL?

This needs a ? instead of a #. # means to show the page starting at a bookmark. Something loosely like: URL?access_token&token_type&expires_in
When you create the value, to send to the second page, it would be something like:
$url=“auth/server.php?” . $access_token . “&” . $token_type . “&” . $expires_in ;
You may need to add quotes around type and expires if they are strings, same for token, too.
And, then, in the server.php file, you retrieve these using GET. Something loosely like this:
$access_token=filter_input(INPUT_GET, “access_token”);
$token_type=filter_input(INPUT_GET, “token_type”);
$expires_in=filter_input(INPUT_GET, “expires_in”);

Now, this is just the basics. I am not familiar with the Yandex API, but, this is how you would pass data from page to page in normal PHP files. You might be able to find more thru the Yandex docs themselves.

Thanks for the response!
Using the Yandex API, it always is reporting https://mail.(my domain)/auth/server.php#access_token=TOKENGOESHERE&token_type=TYPE&expires_in=EXPIRATION and I cannot change this (this is where I’m redirected once I use the OAuth URL). I am wondering if there’s away I can get TOKENGOESHERE with this link base. I’m trying to find another solution, but this is all I have. I can’t find any PHP script directions on Yandex’s docs.

Anything after the # in a URL is not supposed to be sent to the server at all; it’s only used by the browser. You’ll have to use javascript here.

Sponsor our Newsletter | Privacy Policy | Terms of Service