function callService(&$reqTxt, $department, $transtype, $symbol, $shares, $limitprice, $orderid, $username, $password, $currentcash) { global $behaviors; try { $reqTxt = ""; if (!$behaviors[$transtype]) { return "Behavior not implemented: {$transtype}"; } $postData = array("behavior" => $transtype, "token" => getLoginCookie(), "symbol" => $symbol, "shares" => $shares, "limitprice" => $limitprice, "orderid" => $orderid, "username" => $username, "password" => $password, "currentcash" => $currentcash); $ws = new WSRequestManager(); $ws->setServiceAddress("{$department}"); $respTxt = $ws->getData("jsondata=" . json_encode($postData)); $reqTxt = $ws->getLastRequestDetails(); return $respTxt; } catch (Exception $e) { header('HTTP/1.1 500 Internal Server Error'); echo "Error: " . $e->getMessage(); exit; } }
function getProfileInfo() { try { $retval = ""; $reqTxt = ""; $postData = array("behavior" => "getProfileInfo", "token" => getLoginCookie(), "symbol" => "", "shares" => "", "limitprice" => "", "username" => "", "password" => "", "currentcash" => ""); $ws = new WSRequestManager(); $ws->setServiceAddress("TE"); $respTxt = $ws->getData("jsondata=" . json_encode($postData)); $reqTxt = $ws->getLastRequestDetails(); //return $respTxt; //$respTxt = '{"behavior":"getProfileInfo","success":true,"statuscode":0,"statusdesc":["Good to go"],"retval":{"currentcash":8000.00,"holdings":[{"symbol":"INTC","shares":7,"value":100.00},{"symbol":"GOOG","shares":5,"value":10.50},{"symbol":"MSFT","shares":5,"value":1.25}]}}'; $obj = json_decode($respTxt); return $obj->retval; } catch (Exception $e) { header('HTTP/1.1 500 Internal Server Error'); echo "Error: " . $e->getMessage(); exit; } }