Skip to content

Instantly share code, notes, and snippets.

@kpoon
Created January 4, 2011 21:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kpoon/765457 to your computer and use it in GitHub Desktop.
Save kpoon/765457 to your computer and use it in GitHub Desktop.
ColdFusion code to access the StatsMix API.
<!--- In the following example, user variables are indicated by uppercase (ex. API_KEY). --->
<!--- To create a stat (POST) --->
<cfhttp url="http://statsmix.com/api/v1/stats" method="post" charset="utf-8">
<cfhttpparam type="url" name="api_key" value="API_KEY">
<cfhttpparam type="url" name="value" value="VALUE">
<cfhttpparam type="url" name="profile_id" value="PROFILE_ID">
<cfhttpparam type="url" name="metric_id" value="METRIC_ID">
<cfhttpparam type="url" name="generated_at" value="#DateFormat(Now(), "yyyy/mm/dd")# #TimeFormat(Now(), "HH:mm:ss")#">
</cfhttp>
<cfswitch expression="#cfhttp.responseHeader.status_code#">
<cfcase value="200">
<!--- Good response, do nothing. --->
</cfcase>
<cfdefaultcase>
<cfthrow message="Your call to StatsMix failed and returned an HTTP status of #cfhttp.responseHeader.status_code#.">
</cfdefaultcase>
</cfswitch>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment