Skip to content

Instantly share code, notes, and snippets.

@richardhughes260
Last active December 14, 2015 12:38
Show Gist options
  • Save richardhughes260/5087455 to your computer and use it in GitHub Desktop.
Save richardhughes260/5087455 to your computer and use it in GitHub Desktop.
ColdFusion wrapper for Google Chart API If you want images to come from your site only and not multiple locations, like when you are using https. This will accept a URL Parameter for the text and will output the image. There is no image on the local file system to clean up later.
<cfparam default="This is Text!!! :)" name="url.text">
<cfhttp
method="Get"
url="http://chart.apis.google.com/chart?chs=150x150&cht=qr&chl=#url.text#" getAsBinary = "yes" >
<!--- From Ben Nadel --->
<!--- Check to see if we found the image. --->
<cfif (
FindNoCase( "200", cfhttp.Statuscode ) AND
FindNoCase( "image", cfhttp.Responseheader["Content-Type"] )
)>
<!--- We have an image. Now show it! --->
<cfimage source="#cfhttp.filecontent#" action="writeToBrowser">
<cfelse>
<!--- Blast! The image didn't come through. --->
</cfif>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment