-
Notifications
You must be signed in to change notification settings - Fork 0
%20Getting Started
NateFerrero edited this page Sep 25, 2011
·
1 revision
View the Complete API Reference
To use the API outside of the Momentum domain, you will need to implement a simple proxy. For ease-of-setup, a simple PHP proxy can be found at http://58.stage-one.donate.io/api-v1.proxy.php
Save the source of that proxy as a PHP file accessible on your domain, then you will need to specify the proxy path as follows in the next section.
Since jQuery is required for AJAX functionality, add jQuery and then the API script and your proxy location as follows:
<!doctype html>
<html>
<head>
<title>Evolution API Test Page</title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
<script src="http://58.stage-one.donate.io/api-v1.js"></script>
<script>e.proxyURL = '//'+window.location.host+'/path/to/proxy.php';</script>
</head>
</html>
The following example will print the names of the first 12 Charities in a bullet list.
HTML code:
<ul id="charities"></ul>
<script>
// Make a function to display charities
function displayCharities(err, charities) {
if(err)
return alert('There was an error loading charities, ' + err);
var list = '';
charities.forEach( function(charity) {
list += '<li>'+charity.name+'</li>';
} );
// Save the HTML into the list
$('#charities').html(list);
}
// Load the charity list
e.app.community.charities({page_length: 12}, displayCharities);
</script>
JavaScript Code to load project 1:
e.app.community.project(1, function(err, project) {
if(err)
alert('Error, ' + err);
else
alert(project.name);
});
This is what the project
variable would look like:
/* Project Object */
{
_: {
callback: /* The function you passed in as a callback */
class: "App_Community_Project"
version: 1
}
_app: "community"
_method: "@project"
charity: /* Charity Object */
country: null
description: "Serves 400 people with clean water for 20 years. The ..."
href: "//live58.donate.dev:90/momentum/project/1"
id: "1"
link: '<a href="http://live58.donate.dev:90/momentum/project/1">India Water Well</a>'
name: "India Water Well"
photo: "/portal/redirect_photo/project/1"
progress: "699.00"
target: "2200.00"
}