private function request($params)
 {
     $params['username'] = $this->username;
     $params['password'] = $this->password;
     if (empty($this->conn['fd'])) {
         if (!M_Connect($this->conn)) {
             throw new MonetraException(__(M_ConnectionError($this->conn)));
         }
     }
     $identifier = M_TransNew($this->conn);
     foreach ($params as $key => $value) {
         M_TransKeyVal($this->conn, $identifier, $key, $value);
     }
     return $this->executeRequest($identifier);
 }
Esempio n. 2
0
    echo "Could not set non-blocking mode\r\n";
    /* Free memory associated with conn */
    M_DestroyConn($conn);
    return;
}
/* Set a timeout to be appended to each transaction
 * sent to Monetra */
if (!M_SetTimeout($conn, 30)) {
    echo "Could not set timeout\r\n";
    /* Free memory associated with conn */
    M_DestroyConn($conn);
    return;
}
echo "Connecting to {$MYHOST}:{$MYPORT} using {$MYMETHOD}...";
/* Connect to Monetra */
if (!M_Connect($conn)) {
    echo "Connection failed: " . M_ConnectionError($conn) . "\r\n";
    /* Free memory associated with conn */
    M_DestroyConn($conn);
    // free memory
    return;
}
echo "connected\r\n";
/* Allocate new transaction */
$identifier = M_TransNew($conn);
/* User credentials */
M_TransKeyVal($conn, $identifier, "username", $MYUSER);
M_TransKeyVal($conn, $identifier, "password", $MYPASS);
/* Transaction Type */
M_TransKeyVal($conn, $identifier, "action", "admin");
M_TransKeyVal($conn, $identifier, "admin", "GUT");
 function MCVE_Connect(&$conn)
 {
     return M_Connect($conn);
 }