php - LightOpenID authentication using POST method -
is there way authenticate using lightopenid library using post method? exact, after authenticating, google (for example) returns specified url data sent me using method, ends in ugly , long url.
my code is:
define('base_url', 'http://someurl.com'); try { $openid = new lightopenid(); if (!isset($_get['openid_mode'])) { // no openid mode set, authenticate user $openid->identity = 'https://www.google.com/accounts/o8/id'; $openid->realm = base_url; $openid->required = array('contact/email'); header('location: '.$openid->authurl()); } else if ($_get['openid_mode'] == 'cancel') { // user canceled login, redirect them header('location: '.base_url); } else { // authentication completed, perform license check if ($openid->validate()) { $openid->getattributes(); } } } catch (errorexception $e) { }
so after authentication op returns url looks this:
http://someurl.com/index.php?openid.ns=http://specs.openid.net/auth/2.0&openid.mode=id_res&openid.op_endpoint=https://www.googl...
and want op return to:
http://someurl.com/index.php
and send data using post not get.
i've been working on same. see code below. think should help.
<?php require 'lightopenid/openid.php'; try { $openid = new lightopenid; if(!$openid->mode) { if(isset($_get['login'])) { $openid->identity = 'https://www.google.com/accounts/o8/site-xrds?hd=yourdomain.com'; $openid->required = array('nameperson/friendly', 'contact/email' , 'contact/country/home', 'nameperson/first', 'pref/language', 'nameperson/last'); header('location: ' . $openid->authurl()); } ?> <form action="?login" method="post"> <button>login google</button> </form> <?php } elseif($openid->mode == 'cancel') { echo 'user has canceled authentication !'; } else { session_start(); $fname = $openid->ret_fname(); // setting session $lname = $openid->ret_lname(); // setting session $email = $openid->ret_email(); // setting session $_session['admin']['name'] = $fname.' '.$lname; // setting session $_session['admin']['emailid'] = $email; // setting session header('location:approve.php'); // put page/url here.... think should trick !!! } } catch(errorexception $e) { echo $e->getmessage(); }
Comments
Post a Comment