Create the Layer
layer = geoloqi.post 'layer/create', { :name => 'My Sweet Layer', :key => 'my_layer', :description => 'My layer for testing' }
Create Places
For the Calagator layer which reminds people of upcoming events nearby, we create a place record corresponding to the venue of the event. The Geoloqi API will not create duplicate places with the same name, so it's safe to run this multiple times for the same venue.
<?php $place = $geoloqi->request('place/create', array( 'layer_id' => $layerID, 'name' => $event->venue->title, 'description' => trim($event->venue->description.' '. $event->venue->address.' '. $event->venue->url), 'radius' => 500, 'latitude' => $lat, 'longitude' => $lng )); ?>
place = geoloqi.post 'place/create', { :layer_id => layer[:layer_id], :name => event[:venue][:title], :description => event[:venue][:description], :radius => 500, :latitude => event[:venue][:latitude], :longitude => event[:venue][:longitude] }
Create Triggers
For the Calagator layer, we create a trigger at a venue with the message we want to deliver to users.
<?php $geoloqi->request('trigger/create', array( 'place_id' => $place->place_id, 'type' => 'message', 'date_from' => date('c', strtotime('-3 hours', strtotime($event->dateStart))), 'date_to' => date('c', strtotime($event->dateStart)), 'one_time' => 1, 'text' => $message, 'url' => 'http://calagator.org/events/'.$event->id )); ?>
date_from, date_to: The trigger is set to be active 3 hours before the start of the event, and expires at the event start time so people won't get notifications of past events.
one_time: Setting this to "1" ensures a user will only receive this message the first time they enter the place, and will not receive it if they come back. Set to "0" or leave it out if you want the message to be recurring.
text: The text is a sentence we constructed from the event data such as "Are You Smarter than Your Lawyer and Venture Capitalist? at Urban Airship at 11/01 6:30pm". If the text specified is longer than will fit in a push notification or SMS, it will be trimmed automatically.
url: The URL is a link to the event on Calagator. If the message is sent via push notification, clicking on the notification will open the web page. If sent via SMS, the link will be appended to the end of the SMS.
Timeline Stories
What Next?
- Check out a sample project for creating a layer
- Geoloqi API Documentation
- New Wikipedia Layer on Geoloqi Gives You Vision Beyond the Greek Gods (readwriteweb.com)