Terra Dotta Software API Documentation
Back to Terra Dotta Software API Documentation Return to Public Site
Top
Top
Using our original call:
(the following XML packet is formatted for readability)
We can modify the call to return the data in SOAP format by specifying
(the following XML packet is formatted for readability)
We can modify the call to return the data in JSON format by specifying
(the following JSON packet is formatted for readability)
Example 1: Following is an example of using ColdFusion to call the API and returning the data in a SOAP envelope:
Run Example 1 Top
(if your installation does not have any data, this example will not return anything)
Back to Terra Dotta Software API Documentation Top
getProgramTestimonials
Retrieve published testimonial for a specific program.URL
http://{site root}/piapi/index.cfm?callName=getProgramTestimonials
The value for {site root} would represent your installation URL. The values returned from this function are in the following table.
- Table 1: Input arguments for getProgramTestimonials
- Table 2: Return values for getProgramTestimonials
- Example 1: Calling getProgramTestimonials with ColdFusion
Top
Standard Input Parameters (jump to call specific input arguments) | |||
---|---|---|---|
Argument | Type | Required | Meaning |
ResponseEncoding | String | Optional | The data format to be returned by the API call. The value for ResponseEncoding can be one of the following values:
(case insensitive) |
CallBack | Boolean | Optional | Used with JSON only to specify if a callback function will be used or not. |
CallBackName | String | Optional | Used with JSON only to specify the callback function to use. |
Call-specific Input Parameters (jump to standard input arguments) | |||
Argument | Type | Required | Meaning |
program_id | integer | required | Program ID for which to retrieve testimonials for |
IsPublished | Boolean | Optional | A filter to check whether the testimonial is published or not. |
isAnonymous | Boolean | Optional | A filter to check whether the author of the testimonial is anonymous. |
Top
Return Value | Type | Meaning |
---|---|---|
response_data | string | Testimonial response data |
questionnaire_name | String | Testimonial questionnaire name |
app_item_text | string | Question item name |
user_first_name | string | First name of the user that left the testimonial |
user_last_name | string | First name of the user that left the testimonial |
user_middle_name | String | Middle name, is supplied, of the user that left the testimonial |
datecompleted | Date | Date in which the testimonial was completed |
isanonymous | Integer | Is the testimonial anonymous or not. 1 is yes, 0 is no. |
Using our original call:
http://{site root}/piapi/index.cfm?callName=getProgramTestimonials&Program_ID=10001&ResponseEncoding=xml
We would receive a packet of data in XML format (the default), that might resemble the following:
(the following XML packet is formatted for readability)
<testimonials>
<testimonial>
<app_item_text>Question #1</app_item_text>
<datecompleted>2011-05-05 14:22:39</datecompleted>
<isanonymous>0</isanonymous>
<questionnaire_name>Testimonial #1</questionnaire_name>
<response_data>Response...</response_data>
<user_first_name>First Name</user_first_name>
<user_last_name>Last Name</user_last_name>
<user_middle_name>Middle Name</user_middle_name>
</testimonial>
</testimonials>
<testimonial>
<app_item_text>Question #1</app_item_text>
<datecompleted>2011-05-05 14:22:39</datecompleted>
<isanonymous>0</isanonymous>
<questionnaire_name>Testimonial #1</questionnaire_name>
<response_data>Response...</response_data>
<user_first_name>First Name</user_first_name>
<user_last_name>Last Name</user_last_name>
<user_middle_name>Middle Name</user_middle_name>
</testimonial>
</testimonials>
We can modify the call to return the data in SOAP format by specifying
ResponseEncoding=SOAP
:
http://{site root}/piapi/index.cfm?callName=getProgramTestimonials&ResponseEncoding=SOAP&Program_ID=10001
We would receive a packet of XML wrapped within a SOAP envelope that might resemble the following:
(the following XML packet is formatted for readability)
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<testimonials>
<testimonial>
<app_item_text>Question #1</app_item_text>
<datecompleted>2011-05-05 14:22:39</datecompleted>
<isanonymous>0</isanonymous>
<questionnaire_name>Testimonial #1</questionnaire_name>
<response_data>Response...</response_data>
<user_first_name>First Name</user_first_name>
<user_last_name>Last Name</user_last_name>
<user_middle_name>Middle Name</user_middle_name>
</testimonial>
</testimonials>
</soapenv:Body>
</soapenv:Envelope>
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<testimonials>
<testimonial>
<app_item_text>Question #1</app_item_text>
<datecompleted>2011-05-05 14:22:39</datecompleted>
<isanonymous>0</isanonymous>
<questionnaire_name>Testimonial #1</questionnaire_name>
<response_data>Response...</response_data>
<user_first_name>First Name</user_first_name>
<user_last_name>Last Name</user_last_name>
<user_middle_name>Middle Name</user_middle_name>
</testimonial>
</testimonials>
</soapenv:Body>
</soapenv:Envelope>
We can modify the call to return the data in JSON format by specifying
ResponseEncoding=JSON
:
http://{site root}/piapi/index.cfm?callName=getProgramTestimonials&ResponseEncoding=JSON&Program_ID=10001
We would receive a JSON-encoded packet:
(the following JSON packet is formatted for readability)
_cb_getProgramTestimonials({
"TESTIMONIAL":{
"RESPONSE_DATA":"Response...",
"ISANONYMOUS":0,
"APP_ITEM_TEXT":"Question #1",
"DATECOMPLETED":"2011-05-05 14:22:39",
"USER_FIRST_NAME":"First Name",
"QUESTIONNAIRE_NAME":"Testimonial #1",
"USER_MIDDLE_NAME":"Middle Name",
"USER_LAST_NAME":"Last Name"
}
});
"TESTIMONIAL":{
"RESPONSE_DATA":"Response...",
"ISANONYMOUS":0,
"APP_ITEM_TEXT":"Question #1",
"DATECOMPLETED":"2011-05-05 14:22:39",
"USER_FIRST_NAME":"First Name",
"QUESTIONNAIRE_NAME":"Testimonial #1",
"USER_MIDDLE_NAME":"Middle Name",
"USER_LAST_NAME":"Last Name"
}
});
The data returned using JSON encoding is wrapped within the callback function, _cb_getProgramTestimonials()
.
By default, all JSON calls are returned within a callback wrapper function in form of:
_cb_callName()
Where callName
represents the name of the function you originally called.
To override this, you can specify the callBackName
argument, as in:
http://{site root}/piapi/index.cfm?callName=getProgramTestimonials&Program_ID=10001&ResponseEncoding=JSON&callBackName=MyCallBackFunction
This call would return the JSON packet wrapped within the callback function, MyCallBackFunction
, as in:
_cb_MyCallBackFunction(...json-encoded data...)
In your custom pages, you would then create a corresponding function to handle this custom callback function:
<script language="JavaScript" type="text/javascript">
<!--
// <![CDATA[
function _cb_MyCallBackFunction(data)
{
// put additional routines here
}
// ]]>
//-->
</script>
If you would like to receive the data without a callback function, you can use the argument <!--
// <![CDATA[
function _cb_MyCallBackFunction(data)
{
// put additional routines here
}
// ]]>
//-->
</script>
callBack
to override this. Specifying a value of false
for the callBack
argument returns the data without the callback function, as in:
http://{site root}/piapi/index.cfm?callName=getProgramTestimonials&ResponseEncoding=JSON&Program_ID=10001&callBack=false
Note: specifying callBack=true
is implied and is unnecessary for returning JSON data with a callback function.
Example 1: Following is an example of using ColdFusion to call the API and returning the data in a SOAP envelope:
Run Example 1 Top
(if your installation does not have any data, this example will not return anything)
<!---// local variables //--->
<cfparam name="responsePacket" default="[ no response ]" />
<cfparam name="url.program_id" default="10001" />
<!---// connect to the API (GET or POST) //--->
<cfhttp result="httpCall" method="post" url="#REQUEST.CurrentAccount.AccountURL()#piapi/index.cfm">
<cfhttpparam name="callName" type="url" value="getProgramTestimonials" />
<cfhttpparam name="ResponseEncoding" type="url" value="SOAP" />
<cfhttpparam name="Program_id" type="url" value="#url.program_id#" />
</cfhttp>
<!---// ensure the response is in XML format //--->
<cfif isXml(httpCall.fileContent)>
<!---// parse response //--->
<cfset responsePacket = xmlParse(httpCall.fileContent) />
<!---// check to see if an error was thrown //--->
<cfset err = xmlSearch(responsePacket, "//extrainfo") />
<!---// an error was thrown //--->
<cfif isArray(err) and not arrayIsEmpty(err)>
<!---// throw error //--->
<cfthrow message="#err[1].xmlText#" />
<cfabort />
</cfif>
<cfelse>
<!---// additional error checking //--->
</cfif>
<!---// additional code goes here //--->
<h2>Output for 'responsePacket':</h2>
<cfdump VAR="#responsePacket#" />
For additional techniques, be sure to visit the other program calls within these documentation pages.
<cfparam name="responsePacket" default="[ no response ]" />
<cfparam name="url.program_id" default="10001" />
<!---// connect to the API (GET or POST) //--->
<cfhttp result="httpCall" method="post" url="#REQUEST.CurrentAccount.AccountURL()#piapi/index.cfm">
<cfhttpparam name="callName" type="url" value="getProgramTestimonials" />
<cfhttpparam name="ResponseEncoding" type="url" value="SOAP" />
<cfhttpparam name="Program_id" type="url" value="#url.program_id#" />
</cfhttp>
<!---// ensure the response is in XML format //--->
<cfif isXml(httpCall.fileContent)>
<!---// parse response //--->
<cfset responsePacket = xmlParse(httpCall.fileContent) />
<!---// check to see if an error was thrown //--->
<cfset err = xmlSearch(responsePacket, "//extrainfo") />
<!---// an error was thrown //--->
<cfif isArray(err) and not arrayIsEmpty(err)>
<!---// throw error //--->
<cfthrow message="#err[1].xmlText#" />
<cfabort />
</cfif>
<cfelse>
<!---// additional error checking //--->
</cfif>
<!---// additional code goes here //--->
<h2>Output for 'responsePacket':</h2>
<cfdump VAR="#responsePacket#" />
Back to Terra Dotta Software API Documentation Top