Skip to content

Terra Dotta Software API Documentation


Back to Terra Dotta Software API Documentation Return to StudioAbroad

getProgramLocations

Returns a list of all available locations or locations specific to a program.

URL
http://{site root}/piapi/index.cfm?callName=getProgramLocations
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 getProgramLocations 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 gather locations for.


Top
Table 2: Return values for getProgramLocations
Return Value Type Meaning
program_active Integer Whether or not the program is currently active. 1 is yes, 0 or NULL is no.
program_city String City name
program_country String Country name
program_region String Region name
program_latitude Decimal Latitude coordinate for the the program location.
program_longitude Decimal Longitude coordinate for the the program location.
program_location_id Integer Unique identifier for the program-specific location.


Using our original call:
http://{site root}/piapi/index.cfm?callName=getProgramLocations&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)
<locations>
    
<recordcount>1</recordcount>
    
<location>
        
<program_active>1</program_active>
        
<program_city>Tokyo</program_city>
        
<program_country>Japan</program_country>
        
<program_location_id>10024</program_location_id>
        
<program_region>Asia</program_region>
        
<program_latitude>35.61488</program_latitude>
        
<program_longitude>139.5813</program_longitude>
    
</location>
</locations>

We can modify the call to return the data in SOAP format by specifying ResponseEncoding=SOAP:
http://{site root}/piapi/index.cfm?callName=getProgramLocations&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>
<locations>
    
<recordcount>1</recordcount>
    
<location>
        
<program_active>1</program_active>
        
<program_city>Tokyo</program_city>
        
<program_country>Japan</program_country>
        
<program_location_id>10024</program_location_id>
        
<program_region>Asia</program_region>
        
<program_latitude>35.61488</program_latitude>
        
<program_longitude>139.5813</program_longitude>
    
</location>
</locations>
</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=getProgramLocations&ResponseEncoding=JSON&Program_ID=10001
We would receive a JSON-encoded packet:
(the following JSON packet is formatted for readability)
_cb_getProgramLocations(
{
   "recordcount":1,
   "columnlist":"program_active,program_city,program_country, program_location_id,program_region,program_latitude,program_longitude",
   "data":{
      "program_active":[
         1
      ],
      "program_city":[
         "Tokyo"
      ],
      "program_country":[
         "Japan"
      ],
      "program_location_id":[
         10024
      ],
      "program_region":[
         "Asia"
      ]
      "program_latitude":[
         "35.61488"
      ]
      "program_longitude":[
         "139.5813"
      ]
   }
}
);
The data returned using JSON encoding is wrapped within the callback function, _cb_getProgramLocations(). 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=getProgramLocations&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=getProgramLocations&Program_ID=10001&ResponseEncoding=JSON&callBackName=MyCallBackFunction
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="getProgramBrochure" />
    <
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.

Back to Terra Dotta Software API Documentation Top