Skip to content

Terra Dotta Software API Documentation


Back to Terra Dotta Software API Documentation Return to Public Site

getProgramRandomTestimonial

Retrieve published testimonial for a specific program.

URL
http://{site root}/piapi/index.cfm?callName=getProgramRandomTestimonial
The value for {site root} would represent your installation URL. The values returned from this function are in the following table.


Top
Table 1: Input arguments for getProgramRandomTestimonial
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:
    Applicable values:
    (case insensitive)
  • XML - eXtensible Markup Language (default)
  • JSON - JavaScript Object Notation
  • SOAP - Simple Object Access Protocol
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 testimonial for
IsPublished Boolean Optional A filter for checking whether the testimonial is published.
IsAnonymous Boolean Optional A filter for checking whether the testimonial is Anonymous.


Top
Table 2: Return values for getProgramRandomTestimonial
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_middle_name string Middle name of the user that left the testimonial
user_last_name string Last name 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=getProgramRandomTestimonial&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 Name</app_item_text>
        
<datecompleted>2012-05-05 12:00:00</datecompleted>
        
<isanonymous>0</isanonymous>
        
<questionnaire_name>Testimonial Name</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>
        
<program_term>Fall</program_term>
        
<program_year>2012</program_year>
        
<bdualyearterm>0</bdualyearterm>
    
</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=getProgramRandomTestimonial&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> 

We can modify the call to return the data in JSON format by specifying ResponseEncoding=JSON:
http://{site root}/piapi/index.cfm?callName=getProgramRandomTestimonial&ResponseEncoding=JSON&Program_ID=10001
We would receive a JSON-encoded packet:
(the following JSON packet is formatted for readability)
_cb_getprogramrandomtestimonial({
   "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_getProgramRandomTestimonial(). 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=getRandomTestimonial&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 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=getProgramRandomTestimonial&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 using JSON and client-side JavaScript to render the program names as link and indicating whether or not the programs are incoming:
Run Example 1 Top
(be sure to change the ?program_id=xxxxx value in the URL of this example to return real data. If your installation does not have any data, this example may not return anything)

The code for this example is not shown due to size. To see the code, please open the code file piapi/docs/getProgramRandomTestimonial_example1.cfm
Example 2: Following is an example of using ColdFusion to call the API and returning the data in a SOAP envelope:
Run Example 2 Top
(if your installation does not have any data, this example will not return anything)

<!---// local variables //--->
<cfparam name="responsePacket" default="[ no response ]" />

<!---// 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="getProgramRandomTestimonial" />
    <
cfhttpparam name="ResponseEncoding" type="url" value="SOAP" />
</
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.

Back to Terra Dotta Software API Documentation Top