Installation

To install SnagCity on your website, first choose either the Javascript or PHP method.

Javascript method

The Javascript method requires a single line of Javascript in the head of your site's code and then you can use the SnagCity object to place code anywhere on your site.

<!DOCTYPE html>
<html>
<head>
<title>SnagCity Javascript Example</title>
<script src="http://snag.city/api/?licenseKey=YOUR_KEY_HERE"></script>
</head>
<body>
<h1>You're from <script>document.write(snagCity.city);</script></h1>
</body>
</html>

PHP method

The PHP method requires a single PHP file to be loaded in your site and then you can include that file to get access to the SnagCity object to place code anywhere on your site.

First, you download the snagcity.zip file, unzip and put the snagcity.php file in the root folder of your site. Next, update the file to include your license key.

<?php
//authentication
$licenseKey = 'YOUR_KEY_HERE';
...

Then, you include the snagcity.php file in your code and use the snagCity object to display city information on your site.

<?php include_once('snagcity.php'); ?>
<!DOCTYPE html>
<html>
<head>
<title>SnagCity PHP Example</title>
</head>
<body>
<h1>You're from <?php echo $snagCity->city; ?></h1>
</body>
</html>

Get your license key