Skip to content

Instantly share code, notes, and snippets.

@boycaught
Created July 14, 2012 17:53
Show Gist options
  • Select an option

  • Save boycaught/3112362 to your computer and use it in GitHub Desktop.

Select an option

Save boycaught/3112362 to your computer and use it in GitHub Desktop.
CFScript Web Functions
<cfscript>
/**
* WEB FUNCTIONS
**/
remote any function getWebService(){
var targetUrl = '';
var webService = new http();
var content = '';
var thisresult = '';
try {
webService.setMethod("get");
webService.setUrl(targetUrl);
/*
webService.addParam(type="***",name="***",value=***);
*/
content = webService.send().getPrefix();
thisresult = trim(content.filecontent);
if (isJson(thisresult)) {
return deserializejson(thisresult);
} else {
return thisresult;
}
} catch (any e) {
// error handling
thisresult = "Error: " & e.message;
return thisresult;
}
}
remote any function postWebService(){
var authcode = arguments.FOO;
var targetUrl = '';
var webService = new http();
var content = '';
var thisresult = '';
try {
webService.setMethod("post");
webService.setUrl(targetUrl);
/*
webService.addParam(type="formfield",name="FOO",value=arguments.FOO);
*/
content = webService.send().getPrefix();
thisresult = trim(content.filecontent);
if (isJson(thisresult)) {
return deserializejson(thisresult);
} else {
return thisresult;
}
} catch (any e) {
// error handling
thisresult = "Error: " & e.message;
return thisresult;
}
}
</cfscript>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment