Hi all,
I am using plugin : https://moodle.org/plugins/auth_userkey
To get user login URL, It's working fine for me But issue I am facing to redriect.
Please help me.
function getloginurl(){ require_once('curl.php'); $domainname = 'https://yourdomain.com/moodle'; //paste your domain here $wstoken = 'a9d61f9e8c1dec3a3b956adcb8d99862'; //here paste your enrol token $wsfunctionname = 'auth_userkey_request_login_url'; $username = 'admin'; // For demo I put here hardcoded admin as username. if(!empty($username)){ $enrolment = array( 'username' => $username ); $params = array( 'user' => $enrolment ); //header("Content-Type:text/plain"); $serverurl = $domainname . "/webservice/rest/server.php?wstoken=" . $wstoken . "&wsfunction=" . $wsfunctionname; $curl = new curl; //curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); //curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: text/plain')); $restformat = ''; $restformat = ($restformat == 'json')?'&moodlewsrestformat=' . $restformat:''; $resp = $curl->post($serverurl . $restformat, $params); return $resp;exit(); } } redirect(getloginurl());
redirect not working it's take me home page without login.
But print it then given me link to login.
like echo getloginurl();