GitList
Repositories
Help
Report an Issue
vroom360
Code
Commits
Branches
Tags
Search
Tree:
e36c40f
Branches
Tags
master
vroom360
index.php
initial commit
Dev Ghai
commited
e36c40f
at 2013-09-26 06:24:15
index.php
Blame
History
Raw
<!-- To change this template, choose Tools | Templates and open the template in the editor. --> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title></title> </head> <body> <h1>You have reached Web service for VRoom 360 project.</h1> <h2>This is a test page for various things being developed.</h2> <?php require_once 'RequestObject.php'; require_once 'dataendpoint.php'; require_once 'Config.php'; //test function GenerateRequestForTesting() { $config = new Config(); //put all parameters in an array //update user info from profile page //UpdateUserInfo $params = array( 'userid' => 'dev2', 'email' => 'dev2@dev.com', 'zip' => 15219, 'height' => 150, 'sittingHeight' => 10, 'upperLegLength' => 20, 'weightRange' => 14, 'ageRange' => 10, 'gender' => 'Male', 'shirtSize' => 'L', 'shoeSize' => 11.5 ); //get questions depending on the set id. //vehicle model name //GetCarModel $params = array( 'year' => 2010, 'make' => 'Buick', ); //GetPreviousAnswers $params = array ( 'activeSurveyId' => 2 ); //SetNewSurvey $params = array( 'vehicleId' => 21, 'questionSet_id' => 2, 'userId' => 'eve', ); //SetNewUserInfo $params = array( 'username' => 'pappu', 'password' => 'pappu', 'email' => 'devghai@yahoo.com' ); //SetEndSurvey $params = array( 'surveyId' => 2 ); //ResetPassword $params = array( 'loginId' => 'dev' ); //ChangePassword $params = array( 'username' => 'dev', 'newPassword' => 'password', 'oldPassword' => 'dev', ); //GetBadges $params = array( 'loginId' => 'dev' ); //GetSurveysForUser $params = array ( 'loginId' => 'dev' ); //IsAuthorizedUser $params =array( 'username' => 'henry', 'isAdmin' => 'true', 'password' => 'henry', ); //GetCarModel $params = array( 'year' => 1991, 'make' => 'Alfa Romeo', ); //SetNewSurvey $params = array( 'vehicleId' => 21, 'questionSet_id' => 2, 'userId' => 'eve', ); //GetQuestions $params = array( 'questionSetId' => 6 ); //IsAuthorizedUser $params =array( 'username' => 'henry', 'isAdmin' => 'true', 'password' => 'henry', ); /* * {"paramArray":{"username":"henry","badgesArray":[9,8,7,4,5,6,8,7,8,7,1,2,3]},"requestHash":"c542ae701ea370a0b5d1b2907e0315238fdde0d7","call":"SetBadges"} */ $badgesArray = array(); for($i = 1; $i<5; $i++) { $badgesArray []= $i; } $badgesArray = array(9,8,7,4,5,6,8,7,8,7,1,2,3); //SetBadges $params = array( 'userid' => 'henry', 'badgesArray' => $badgesArray ); //GetPreviousAnswers $params = array ( 'activeSurveyId' => 221 ); //put all parameters in an array //update user info from profile page //UpdateUserInfo $params = array( 'userid' => 'dev2', 'email' => 'dev2@dev.com', 'zip' => 15219, 'height' => 150, 'sittingHeight' => 10, 'upperLegLength' => 20, 'weightRange' => 14, 'ageRange' => 10, 'gender' => 'Male', 'shirtSize' => 'L', 'shoeSize' => 11.5 ); //make a request $request = new RequestObject(sha1('UpdateUserInfo'), "UpdateUserInfo", $params); //json_encode the request $json = json_encode($request ); echo "<p><b>Generating request with following JSON:</b><br/>$json</p>"; if(!$config->IsConnectionEncryptionEnabled()) { return $json; } //encrypt the request $encryptor = new Crypt_RSA(); if(!$encryptor->loadKey($config->GetRequestPublicKey(), CRYPT_RSA_PUBLIC_FORMAT_PKCS1)) { die('<b>Loading public key for sending data to server failed</b>'); } return $encryptor->encrypt($json); } $generatedRequest = GenerateRequestForTesting(); echo "<p><b>generated request:</b><br/> $generatedRequest</p>"; $decryptedRequest = DecryptRequest($generatedRequest); echo "<p><b>Decrypted request:</b><br/> "; var_dump($decryptedRequest); $response = GetResponse($decryptedRequest); echo "<p><b>Response by application:</b><br/></p>"; var_dump($response); echo "<p><b>Going to send following to client:</b><br/></p>"; SendResponse($response); ?> </body> </html>