Skip to content

Instantly share code, notes, and snippets.

@soulcyon
Created November 22, 2012 20:53
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save soulcyon/4132883 to your computer and use it in GitHub Desktop.
Save soulcyon/4132883 to your computer and use it in GitHub Desktop.
NJIT Login via PHP
<?php
/**
* NJIT Login Script (11/20/2012)
*
* This simulates a real NJIT login transaction using CURL requests. You can port this to any
* SunGard Luminis Platform, such as Middlesex County College and others. The basic transaction
* requires a user, password and uuid fields to be sent via POST request. The validation mechanism
* simply checks for the string "loginok.html" within the result HTML. Beware, other login systems
* will require a different type of validation.
*
* @author Sashank Tadepalli <dijjit@gmail.com>
* @license Creative Commons Attribution 3.0 Unported License.
* @version 1.0
* @link http://dijjit.com/php/njit-login-php/
*/
function njit_login($user, $pass){
// user=UCID&pass=pass&uuid=0xACA021
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://cp4.njit.edu/cp/home/login");
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query(array(
"user" => $user,
"pass" => $pass,
"uuid" => "0xACA021"
)));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch);
curl_close($ch);
// Logout to kill any sessions
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://cp4.njit.edu/up/Logout?uP_tparam=frm&frm=");
curl_exec($ch);
curl_close($ch);
// Return validation bool
return strpos($result, "loginok.html") !== false;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment