-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.htm
43 lines (42 loc) · 1.9 KB
/
example.htm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>Test Ajax JS</title>
<!-- INCLUDE JS FILES - ALWAYS HttpClient.js and Element.js, for Invoice, Recurring and Estimate include BaseInvoice.js as well -->
<script language="javascript" type="text/javascript" src="library/FreshBooks/HttpClient.js"></script>
<script language="javascript" type="text/javascript" src="library/FreshBooks/Element.js"></script>
<script language="javascript" type="text/javascript" src="library/FreshBooks/Client.js"></script>
<!-- helper js, defines dump() function similar to php print_r() -->
<script language="javascript" type="text/javascript" src="library/dumper.js"></script>
<script language="javascript" type="text/javascript">
//<!--
//you API url and token obtained from freshbooks.com
var url = 'your-url-please-replace';
var token = 'your-token-please-replace';
//proxy server script - if your server doesn't support php try creating similar file in supported server side technology
var proxyUrl = 'proxy.php';
//init global FreshBooks_HttpClient
var httpClient = new FreshBooks_HttpClient(url,token,proxyUrl);
function getClient(){
//new Client object
var client = new FreshBooks_Client();
//try to get client with client_id 1
if(client.get(1)){
//investigate populated data
document.getElementById('response').value = dump(client);
}
else{
//no data - read error
document.getElementById('response').value = client.lastError;
}
}
//-->
</script>
</head>
<body>
<h1>FreshBooks API js library Example</h1>
<input type="button" name="test" id="test" value="Get Client ID 1" onclick="getClient();" />
<textarea id="response" name="response" rows="5" cols="60" style="width:100%; height: 300px;"></textarea>
</body>
</html>