Created
July 14, 2012 17:53
-
-
Save boycaught/3112362 to your computer and use it in GitHub Desktop.
CFScript Web Functions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <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