FORGEBOX Enterprise 🚀 - Take your ColdFusion (CFML) Development to Modern Times! Learn More...

userstackcfc

v1.0.0 Public

userstackcfc

A CFML wrapper for the userstack API. Use it to lookup and parse user-agent strings.

Feel free to use the issue tracker to report bugs or suggest improvements!

Acknowledgements

This project borrows heavily from the API frameworks built by jcberquist. Thanks to John for all the inspiration!

Table of Contents

Quick Start

Use of the component .

userstack = new path.to.userstackcfc.userstack( access_key = 'xxx' );

ua = "Mozilla/5.0 (iPad; U; CPU OS 3_2_1 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Mobile/7B405";

result = userstack.detect( ua );

writeDump( var='#result#' );

Setup and Authentication

To get started with the Userstack API, you'll need an Access Key.

Once you have this, you can provide it to this wrapper manually when creating the component, as in the Quick Start example above, or via an environment variables named USERSTACK_ACCESS_KEY, which will get picked up automatically. This latter approach is generally preferable, as it keeps hardcoded credentials out of your codebase.

A Note About HTTPS

For reasons I don't understand, the secure endpoint for the API is restricted to paid plans. This wrapper implements the HTTPS endpoint as the default. Consequently, if you are on the free tier, you'll need to manually override the baseurl when you first init the component, like this:

  userstack new path.to.userstackcfc.userstack(
    baseUrl = 'http://api.userstack.com',
    access_key = 'xxx'
  );

Reference Manual

detect( required string ua, string fields, string callback, string output )

Lookup a single user-agent. The parameter ua specifies the User-Agent string to be looked up. The parameter fields [optional] can be used to specify API response field(s). Further docs


Dependencies (0)


Dev Dependencies (0)


 

$ box install userstackcfc

No collaborators yet.
     
  • {{ getFullDate("Mar 13 2021 12:03 AM GMT") }}
  • {{ getFullDate("Mar 13 2021 12:03 AM GMT") }}
  • 259
  • 0
  • 0