Using the API: moneytrackin’ netvibes module example
Deprecated: Please use the new improved Netvibes UWA module
Edit: *** Solved *** See this post
There is a problem with the user/password auth’ing. We have a javascript function that encrypts the password on the client side before send it, and it’s not working right now. Maybe netvibes wanted to increase the security by not allowing javascript execution at all. We have mailed them and let you know then it’s solved.
Here we’ll present a working example of the moneytrackin’ public API, the netvibes module. You can add it to your netvibes’ page from this URL: http://www.moneytrackin.com/netvibes/
Our API is bases on the SOAP standard, so accessing their methods is just as easy as this:
$client = new SoapClient(“http://www.moneytrackin.com/api/wsdl/”);
// And call a method (defined on the help sectio as well as on the wsdl endpoint)
try {
$result = $client->listProjects(
“username”,
“password”);
} catch (SoapFault $exception) {
echo “SOAP ERROR -> “.$exception->faultstring;
}
Note that we are using php5 (soap and simplexml extensions), but you can also get it working on php4 with the NuSOAP free library
Continue reading for the full source code of our netvibes module
<meta http-equiv=“Content-Type” content=“text/html; charset=utf-8″ />
<link rel=“stylesheet” type=“text/css” /><script type=“text/javascript”>You have to enter your username / password. Please edit it.// Initialize the connection
$client = new SoapClient(“http://www.moneytrackin.com/api/wsdl/”);
if (isset($_POST[“project”])) { // Here we handle the insert form
$insert_ok=true;
try {
$ins_res = $client->insertTransaction(
$_COOKIE[‘name’],
$_COOKIE[‘password’],
$_POST[“project”],
$_POST[“description”],
$_POST[“amount”],
$_POST[“date”],
$_POST[“tags”]
);
} catch (SoapFault $exception) {
$insert_ok=false;
echo “Insert transaction: SOAP ERROR -> “.$exception->faultstring;
}
if ($insert_ok) echo “
<p align=”center“><b>Transaction inserted successfully!</b></p>
“;
}
$ok = true;
function getbalance($proj) {
global $client;
global $ok;
// get the main account’s balance
try {
$balance = $client->getBalance(
$_COOKIE[‘name’],
$_COOKIE[‘password’],
$proj);
$sxe = simplexml_load_string($balance);
return $sxe->balance;
} catch (SoapFault $fault) {
$ok = false;
return “SOAP ERROR: “.$fault->faultstring;
}
}
echo “
“;
// table showing the projects and their balance
echo “
<table width=”70%“>
<tr>
<td align=”center” colspan=”2“><b>”.$_COOKIE[‘name’].“’s balances</b></td>
</tr>
<tr>
<td colspan=”2“></td>
</tr>
<tr>
<td><a xhref=”http://www.moneytrackin.com/home/" mce_href="http://mo.neytrack.in/home/" >Main project</a></td>
<td><b>“. getbalance(”“) .”</b></td>
</tr>
<tr>
<td><a xhref=“http://www.moneytrackin.com/project/%22.$project%5B” mce_href=“http://www.moneytrackin.com/project/%22.$project%5B” >“. utf8_decode($project->name) .”</a></td>
<td><b>“. getbalance($project[’id’]) .”</b></td>
</tr>
</table>
“;
?>
<form action=”/netvibes/” id=”insert” method=”post“>
<table width=”75%“>
<tr>
<td align=”center” colspan=”2“><b>Insert a transaction</b></td>
</tr>
<tr>
<td colspan=”2“></td>
</tr>
<tr>
<td><label for=”description“>Description</label></td>
<td><input type=”text” id=”description” name=”description“></input></td>
</tr>
<tr>
<td><label for=”amount“>Amount</label></td>
<td><input type=”text” id=”amount” name=”amount“></input></td>
</tr>
<tr>
<td><label for=”date“>Date <i>(dd/mm/yyyy)</i></label></td>
<td><input type=”text” id=”date” name=”date“></input></td>
</tr>
<tr>
<td><label for=”tags“>Tags</label></td>
<td><input type=”text” id=”tags” name=”tags“></input></td>
</tr>
<tr>
<td><label for=”project“>Project</label></td>
<td><select id=”project” name=”project“> <option value=”NULL“>Main</option> <option value=”\“”.$id.“\”“>“.$name.”</option> </select></td>
</tr>
<tr>
<td colspan=“2″></td>
</tr>
<tr>
<td align=“center” colspan=“2″><input type=“submit” value=“Insert” name=“add”></input> /></td>
</tr>
</table>
</form>// Now the "configuration" form
?>
<form method=“post” id=“moneytrackin_form” class=“configuration”>
<table width=“75%”>
<tr>
<td><label>Name :</label></td>
<td><input type=“text” name=“name”></input></td>
</tr>
<tr>
<td><label>Password :</label></td>
<td><input type=“password” id=“moneytrackin_pass” name=“password”></input></td>
</tr>
<tr>
<td align=“center” colspan=“2″><input type=“submit” onclick=“document.getElementById(’moneytrackin_pass’).value = hex_md5(document.getElementById(’moneytrackin_pass’).value)” value=“ok” name=“buttn”></input></td>
</tr>
</table>
</form><script type=“text/javascript”>
// Here we had to paste the whole md5.js content because netvibes didn’t support including the file. Omitted for brevity
</script>
The paste above seems to be incomplete, feel free to download the whole file from here: Moneytrackin’ netvibes module

May 24th, 2006 at 10:33 pm
[…] Edit: take a look at this post for a working example […]