コード例 #1
0
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;
    }
}
コード例 #2
0
ファイル: index.php プロジェクト: nordquip/sousms
function parseCredentials($un, $pwd, &$token, &$expires)
{
    try {
        $postData = array("behavior" => "getTokenFromCredentials", "credentials" => new Credentials());
        $postData["credentials"]->username = $un;
        $postData["credentials"]->password = $pwd;
        $ws = new WSRequestManager();
        $ws->setServiceAddress("UA");
        $respTxt = $ws->getData("jsondata=" . json_encode($postData));
        //return $respTxt;
        $respObj = json_decode($respTxt);
        $token = $respObj->token;
        $expires = new DateTime($respObj->expires);
        return $respObj->statusdesc;
    } catch (Exception $e) {
        header('HTTP/1.1 500 Internal Server Error');
        echo "Error: " . $e->getMessage();
        exit;
    }
}
コード例 #3
0
ファイル: profile.php プロジェクト: nordquip/sousms
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;
    }
}