| API Docs Home |
| <iframe name="zohoiam"
src="https://accounts.zoho.com/login?servicename=AaaServer&serviceurl=http://creatorapps.zoho.com/expensetracker/index1.php&logout=true"></iframe> |
| $ticket= $_GET["IAMAGENTTICKET"]; |
| // php code snippet. The following are the
parameters passed from the AddIncome Form. $ticket = $_POST['ticket']; $apikey = $_POST['apikey']; $un=$_POST['username']; $Source = $_POST['Source']; $d = $_POST['Date_field']; $notes = $_POST['Notes']; $amt = $_POST['Amount']; // Actual api call session=curl_init('http://creator.zoho.com/api/json/expensetracker/IncomeForm/add/' . 'zc_ownername=ptkanvignesh' . '&apikey=' . $apikey . '&username=' . $un . '&Date_field=' . $d . '&Amount=' . $amt . '&Notes=' .$notes . '&Source=' . $Source); // Here // expensetracker is the application name // IncomeForm is the form created for Adding Income in ZohoCreator // Add is the operation //zc_ownername is the name of the application owner // apikey is the apikey for the one who uses this api. In this case APIKey for the user ptkanvignesh. //Date_field, Amount, Notes, Source are the Deluge Field names for the IncomeForm. curl_setopt($session, CURLOPT_POST,1); curl_setopt($session, CURLOPT_HEADER, ($headers == "true") ? true : false); curl_setopt($session, CURLOPT_FOLLOWLOCATION, true); curl_setopt($session, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($session); $json = parse_json($response); // Here we use the POST request for adding the Income. The response is in JSON format, which contains the status of the operation. |
| //PHP code snippet. $apikey = $_POST['apikey']; $uname = $_POST['username']; $spentfor = $_POST['SpentFor']; $category = $_POST['Category']; $paid_through = $_POST['PaidThrough']; $d = $_POST['Date_field']; $notes = $_POST['Notes']; $amt = $_POST['AmountSpent']; $ticket = $_POST['ticket']; //The Actual API call. $session = curl_init('http://creator.zoho.com/api/json/expensetracker/ExpenseForm/add/' . 'sharedBy=ptkanvignesh' . '&apikey=' . $apikey . '&username=' . $uname . '&SpentFor=' . $spentfor . '&Category=' . $category . '&PaidThrough=' . $paid_through . '&Date_field=' . $d . '&AmountSpent=' . $amt . '&Notes=' .$notes); // Here // expensetracker is the application name // ExpenseForm is the form created for Adding Expense in ZohoCreator // Add is the operation //zc_ownername is the name of the application owner // apikey is the apikey of the one who uses this api. In this case APIKey for the user ptkanvignesh. //SpentFor, Category, PaidThrough, Date_field, AmountSpent and Notes are the Deluge Field names for the ExpenseForm. curl_setopt($session, CURLOPT_POST,1); curl_setopt($session, CURLOPT_HEADER, ($headers == "true") ? true : false); curl_setopt($session, CURLOPT_FOLLOWLOCATION, true); curl_setopt($session, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($session); $json = parse_json($response); // Here we use the POST request for adding the Income. The response is in JSON format, which contains the status of the operation. |
|
function parse_json($resp) { $json = new Services_JSON(); $phpobj2 = $json->decode($resp); return $phpobj2; } // Here Services_JSON is the JSON parser for parsing the JSON response. |
|
$apikey = $_GET['akey']; $usname = $_GET['username']; $ticket = $_GET['ticket']; $session=curl_init('http://creator.zoho.com/api/json/expensetracker/view/ExpenseView/apikey=' . $apikey . '&limit=1000&startindex=1' . '&ticket=' . $ticket . '&raw=true'.'&zc_ownername=ptkanvignesh'); // here // ExpenseView is the name of the view // limit is the maximum number of records to be fetched. // startindex is the starting index in the database // zc_ownername is the name of the owner of the application. curl_setopt($session, CURLOPT_GET,1); curl_setopt($session, CURLOPT_HEADER, ($headers == "true") ? true : false); curl_setopt($session, CURLOPT_FOLLOWLOCATION, true); curl_setopt($session, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($session); $json = parse_json($response); Here we use a GET request to send the request and the data is returned in JSON format. |
|
$entertainment=0; $fud=0; $rent=0; $shopping=0; $others=0; $avg=0; $exceedCount=0; $dummyArr = $json->ExpenseForm; $length = sizeof($dummyArr); for($index = 0; $index< $length; $index+=1) { $cat = $json->ExpenseForm[$index]->Category; if((string) $cat=='Entertainment') { $entertainment = $entertainment + $json->ExpenseForm[$index]->AmountSpent; } if((string) $cat=='Food') { $fud = $fud + $json->ExpenseForm[$index]->AmountSpent; } if( (string) $cat=='Rent') { $rent = $rent + $json->ExpenseForm[$index]->AmountSpent; } if( (string) $cat=='Shopping') { $shopping = $shopping +$json->ExpenseForm[$index]->AmountSpent; } if( (string) $cat=='Others') { $others = $others + $json->ExpenseForm[$index]->AmountSpent; } } $avg = ( $entertainment + $fud + $rent + $shopping + $others ) / 5; $totalExpense = $entertainment + $fud + $rent + $shopping + $others; |
| $apikey = $_GET['akey']; $usname = $_GET['username']; $ticket = $_GET['ticket']; $sessionIncome=curl_init('http://creator.zoho.com/api/json/expensetracker/view/IncomeView/apikey=' .$apikey.'&limit=100&startindex=1'.'&ticket='.$ticket.'&raw=true'.'&zc_ownername=ptkanvignesh'); // here // ExpenseForm curl_setopt($session, CURLOPT_GET,1); curl_setopt($session, CURLOPT_HEADER, ($headers == "true") ? true : false); curl_setopt($session, CURLOPT_FOLLOWLOCATION, true); curl_setopt($session, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($session); $jsonForIncome = parse_json($response); Here we use a GET request to send the request and the data is returned in JSON format. |
|
$dummyArr1 = $jsonForIncome->IncomeForm; $length1 = sizeof($dummyArr1); for($ind = 0; $ind<$length1; $ind+=1) { $totalIncome = $totalIncome + $jsonForIncome->IncomeForm[$ind]->Amount; } if($totalIncome < $totalExpense ) { $savings = 0; } else { $savings = $totalIncome - $totalExpense; } |
Expense Tracker in FaceBook:
The Expense Tracker application is also integrated in FaceBook. The following is the snap shot of expense tracker application in face book.
Refer : FaceBook
ExpenseTracker
Conclusion: The API
will open up lot of avenues for external websites to colloborate
with ZohoCreator Forms/Views. The above example serves as a
starting point for API users to get started with ZohoCreator
API. For support contact support[at]zohocreator[dot]com. We need to
provide the link for the documentation here.
To know more about Creator APIs refer: API Docs