$siteId = 'modx509932169b94e4.20119292';
$account = 'cms';
$password = 'cms2012';
$_connectorURL = 'http://localhost/modx.desa';
$_cookiefile = tempnam('/tmp', "CURL");
/* Initialise CURL and set the return transfer and cookie options */
$_curlSession = curl_init();
curl_setopt($_curlSession, CURLOPT_RETURNTRANSFER, true);
curl_setopt($_curlSession, CURLOPT_COOKIEFILE, $_cookiefile);
curl_setopt($_curlSession, CURLOPT_COOKIEJAR, $_cookiefile);
$_siteIdString = $siteId;
curl_setopt($_curlSession, CURLOPT_HTTPHEADER, array($_siteIdString));
curl_setopt($_curlSession, CURLOPT_URL, $_connectorURL . '/security/login.php');
$codedPassword = urlencode($password);
curl_setopt($_curlSession, CURLOPT_POST, true);
$loginstring = 'username=' . $account . '&password=' . $codedPassword . '&login_context=mgr';
curl_setopt($_curlSession, CURLOPT_POSTFIELDS, $loginstring);
$result = curl_exec($_curlSession);
var_dump($result);
I think you might try SimpleXML object to get the content, then convert it again to json. Or write a plugin which register to OnManagerAuthentication/OnManagerLogin
More on those events are on rtfm:
http://rtfm.modx.com/display/revolution20/OnManagerLogin
http://rtfm.modx.com/display/revolution20/OnManagerAuthentication
For even more events:
http://rtfm.modx.com/display/revolution20/System+Events
Quote from: nepheus at Nov 12, 2012, 04:25 AMI think you might try SimpleXML object to get the content, then convert it again to json. Or write a plugin which register to OnManagerAuthentication/OnManagerLogin
More on those events are on rtfm:
http://rtfm.modx.com/display/revolution20/OnManagerLogin
http://rtfm.modx.com/display/revolution20/OnManagerAuthentication
For even more events:
http://rtfm.modx.com/display/revolution20/System+Events
Ok thanks I'm trying to fix the provisioner plugin wich logs in thru curl.
Quote from: juanitomint at Nov 12, 2012, 05:56 AM
Quote from: nepheus at Nov 12, 2012, 04:25 AMI think you might try SimpleXML object to get the content, then convert it again to json. Or write a plugin which register to OnManagerAuthentication/OnManagerLogin
More on those events are on rtfm:
http://rtfm.modx.com/display/revolution20/OnManagerLogin
http://rtfm.modx.com/display/revolution20/OnManagerAuthentication
For even more events:
http://rtfm.modx.com/display/revolution20/System+Events
Ok thanks I'm trying to fix the provisioner plugin wich logs in thru curl.
It replies with HTML cos the login fails on 2.2 and above, if you fix this give me a shout.
Is it not setting the error class so it handles the login processor response properly? Or how are you calling the login processor?
See http://rtfm.modx.com/display/revolution20/Loading+MODx+Externally (first example) for details on loading the error.modError service.