This blogpost isn’t gonna be about .net but PHP instead. I recently switched from my old blog system to a wordpress system. WordPress has a plugin to enable logins/registation through openId/OAuth through many of the social sites like: Twitter, LinkedIn and Gmail. This plugin is called JanRain engage
The plugin makes use of the JanRain engage service for which you can register free of charge for a key to enable this service in your website. After you install this plugin you get an option in the wordpress admin screen like seen below:
After you put in the api key and enable the options you’re ready to go!
Hey, on windows hosting it still doesn’t work!
It appears that there’s a bug in the plugin that does not correct HTTPS correctly on windows based php hosting. It tries to redirect to the https version of your site but because you didn’t enable it, it comes up with a 404. If you want to fix this you have to take the following steps:
1.If you go into the plugin/rpx directory there should be a file there called rpx.v.php. In that file look at line 1437. There should be the following line of code:
$this_url = (!empty($_SERVER['HTTPS'])) ? 'https://'.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'] : 'http://'.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
What this code does is the following: append http/https to the tokenurl. The tokenurl is used to redirect back to your current page after a login attempt. They check for an empty $_SERVER[‘https’] but as found in the php manual in windows hosting $_SERVER[‘https’] isn’t an empty string but is set to ‘Off’ instead as can be seen from the php manual excerpt below:
Set to a non-empty value if the script was queried through the HTTPS protocol.
Note: Note that when using ISAPI with IIS, the value will be off if the request was not made through the HTTPS protocol.
2.Change the code to:
$this_url = (!empty($_SERVER['HTTPS'])) && strtolower($_SERVER['HTTPS']) != 'off' ? 'https://'.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'] : 'http://'.$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
And you’re all set to go!