Welcome Guest, Not a member yet? Register   Sign In
URL has a # instead of a ?
#1

(This post was last modified: 11-01-2021, 06:44 PM by richb201.)

I am trying to get a URL  that has a # sign instead of a ?
PHP Code:
http://staging.researchonline.com:8181/index.php/Configure#access_token=eyJraWQiOiJ4Q3VXZFVIRDBSNlJU 
I am trying to get the access_token. I tried using $_GET['access_token'] but that fails. Is there any way that I can see the entire URL so that I can "cut it up" with parse_url() and get the access_token? 

Parse_url requires the url. Where can I get that from?

I tried using
$config['enable_query_strings'] = TRUE;
$config['access_token'] = '#';

But this results in access_token=NULL.
What am I doing wrong?
proof that an old dog can learn new tricks
Reply
#2

@richb201,

You’re doing nothing wrong it is just not possible due to the current specifications.

https://stackoverflow.com/questions/3664...erver-side
Reply
#3

Thx John..
proof that an old dog can learn new tricks
Reply
#4

I have been informed that another way to get the calling URL is to use javascript.

document.getElementById("demo").innerHTML ="Page location is " + window.location.href;

Can someone tell me how I can use javascript that has window.location.href in it to get the URL?
proof that an old dog can learn new tricks
Reply
#5

If the url comes from your own application, then use a ? not a # when you first create this url. They are not the same. 

The "?" is used for query string, where you want to get parameters from the url like you are trying to do. 
The "#" is used to scroll the page to the id following the #. 

The url you posted doesn't make a lot of sense. It should be 
Code:
http://staging.researchonline.com:8181/index.php/Configure?access_token=eyJraWQiOiJ4Q3VXZFVIRDBSNlJU
CodeIgniter 4 tutorials (EN/FR) - https://includebeer.com
/*** NO support in private message - Use the forum! ***/
Reply
#6

(This post was last modified: 11-02-2021, 06:30 PM by richb201.)

Hey Beer. It comes from Okta which is an outh2 application. After discussing with Okta's techs we think that the URL could be seen with javascript's window.location.href. Then I just need to get it back into my CI3 application so I can decode it. I haven't worked in js in a while and don't remember how to do it.
proof that an old dog can learn new tricks
Reply
#7

That's weird they use non standard url like that. You shouldn't have to jump through hoops to make it work.

But yeah, if you really want to read the portion after the #, I think your only solution is to grab the url with JavaScript and send it to your server. Then in your CI application you can use parse_url() to extract all the component, including the fragment (after the #).
CodeIgniter 4 tutorials (EN/FR) - https://includebeer.com
/*** NO support in private message - Use the forum! ***/
Reply
#8

(This post was last modified: 11-02-2021, 07:06 PM by John_Betong.)

@richb201,

This may be useful - view page $_SERVER headers:
PHP Code:
echo <pre>print_r($_SERVERTRUE), </pre>
Reply
#9

Thanks. I already checked all the fields through the $_SERVER in the debugger. It is not there. I am just hoping that javascript can see it.
proof that an old dog can learn new tricks
Reply
#10

(This post was last modified: 11-03-2021, 12:22 PM by richb201.)

OK. I managed to hire someone who wrote code to get the access_token into my session variable. I tested it on a jwt decode app. Seems OK. It appears as if the payload data contains a json field that I need. Is there some php function that will decode into the payload into json items?
proof that an old dog can learn new tricks
Reply




Theme © iAndrew 2016 - Forum software by © MyBB