Beer Mapping API Code Examples:

This page will be displaying multiple examples of ways to interact with the Beer Mapping API. Currently we are only displaying php5 functions using simplexml, but we will eventually be displaying javascript/ajax and other types of interactions.

If you would like to submit code examples, please feel free to contact us about it. If we post them here, we will also display a link to your application.


A php5 Locquery Example:

This example is performing a location query for the term "Goose Island" We have tried to keep example as simple and readable as possible so we have separated html tags onto their own lines away from the content.

	<?php
	$name_query = 'goose+island';
	//using simplexml we will load the proper url for a location query (substitute your api key of course)
	$xml = simplexml_load_file('http://beermapping.com/webservice/locquery/API_KEY/'.$name_query);
	//we will loop through any possible returned values.
	foreach($xml->location as $location){
		//if we want to use the unique id: $location->id;
		
		//first we print the location name and link to the review page
		echo '<p><a href="'.$location->reviewlink.'">';
		echo $location->name;
		echo '</a>';
		echo '<br />';
		//next we echo address:
		echo  $location->street;
		echo '<br />';
		echo $location->city.', '. $location->state.' '.$location->zip;
		echo '<br />';
		echo $location->country;
		echo '<br />';
		echo $location->phone;
		echo '</p>';
	}
	?>
	

results:

Goose Island - Clybourn
1800 North Clybourn Avenue
Chicago, IL 60614
United States
(312) 915-0071

Goose Island - Wrigleyville
3535 N. Clark Street
Chicago, IL 60657
United States
(773) 832-9040

Goose Island Fulton Street Brewery
1800 West Fulton Street
Chicago, IL 60612
United States
(312) 226-1119

Goose Island Kiosk - ORD airport
Terminal 3
Chicago, IL 60018
United States

Goose Island - ORD airport
Terminal 1 Gate C 8
Chicago, IL 60018
United States

 


A php5 Locimage Example:

This example is performing a location image query for the id "1530". We know that this is the id for the Map Room in Chicago because we did a locquery for it earlier. We have tried to keep example as simple and readable as possible so we have separated html tags onto their own lines away from the content.

	<?php
	$image_query = '1530';
	//using simplexml we will load the proper url for a location image query (substitute your api key of course)
	$xml = simplexml_load_file('http://beermapping.com/webservice/locimage/API_KEY/'.$image_query);
	//we will loop through any possible returned values.
	foreach($xml->location as $location){
		echo '<p>';
		echo '<a href="';
		echo $location->directurl;
		echo ' alt="'.$location->caption.'" title="'.$location->caption.'"';
		echo '">';
		echo '<img src="';
		echo $location->thumburl;
		echo '" alt="" title="" />';
		echo '</a>';
		echo '<br />';
		echo $location->caption;
		echo '<br />';
		echo '<a href="';
		echo $location->crediturl;
		echo '" alt="credit for this image" title="credit for this image">';
		echo $location->credit;
		echo '</a>';
		echo '</p>';
	}
	?>
	

results:



Evil_Keith


Woody, we've warned you
Evil_Keith



Evil_Keith


Taps & Bottles - 06/09
BahHumBrew

 

Beer Mappers Online:
93 Guests, 0 Users