Does anyone have some sample PHP code that will read the access_token parameter from the URL? I am using Implicit Authorization, and after I login from the Ring Central login screen, I am redirected to my intranet's website, and the URL looks like:
I know normally, php would use the following: $_GET["access_token"]
However, due to there being a hash mark after "my_redirect_page.php", this doesn't work. In fact, I spent hours googling this and the main answers involved using javascript to parse and store the portion of the URL after the hash mark as follows. Then everything I tried to pass the javascript variable to PHP, and everything I read said to do it in a cookie, but tried as I might, I couldn't get that to work.
var hash = window.location.hash.substr(1);
document.cookie = 'url=' + document.write(hash);
var result = hash.split('&').reduce(function (result, item) {
var parts = item.split('=');
result[parts[0]] = parts[1];
return result;
}, {});
Another thing I tried was to set the php variable as follows. And I was able to echo the URL parameters as one long string to the screen, it seemed I couldn't use explode or strpos to parse $hash . It was as though the variable was blank except for the echo command. :
$hash = "<script>document.write(hash);</script>";
echo $hash;
$access_token_position = strpos($hash,"=");
I must be missing something simple hopefully. There must be sample code for the 2-legged auth (implicit) written in PHP. I found some for the 3-legged auth on the Ringcentral website but kept getting errors.
In any case, all I need to do is capture the resulting value for the access_token so I can use it in an API call in the simplest way possible in PHP.
All the php examples on the Ringcentral developer site use password authentication and I want to use implicit authentication.
Though I did find the one for the 3-legged auth, but after setting it up, kept getting the error:
Fatal error: Call to undefined method RingCentralSDKPlatformPlatform::authUrl() in /var/www/html/ppt_portal/public_html/ringcentral/index.php on line 16
I'm OK using the RingCentral PHP SDK, or not. In this case, I am not using the PHP SDK.
Thank you.