API Libraries

Libraries

It is not hard to consume the Tagcrumbs web service as soon as you have figured out how to use your OAuth library of choice. But it is even easier to use the Tagcrumbs web service if you don’t have to take care about OAuth and Request details and parsing XML or JSON responses yourself.

If you develop an application for the Tagcrumbs platform please consider modeling the OAuth and response parsing into a separate open-source library that you can release. This way, others can help you to improve your library and everybody can use existing work and doesn’t have to reinvent the wheel.

You can use the official Tagcrumbs fixtures to unit-test your library. They are available on http://github.com/tagcrumbs/fixtures/tree/master.

Ruby Gem

To test our web service in every aspect we developed a Ruby Gem. We released it as an open source tool and everybody can use in their applications. It might also give you some inspiration on how to model a library for another programming language.

Feature summary:

• ActiveRecord-like interface

• Support for Signed and Protected Requests

• Automatic loading of associated Resources when they are accessed (just like ActiveRecord associations)

• XML and JSON support

• URLs are loaded from the web service and not built manually

• A console program to interactively create new Placemarks or to create Placemarks by passing command line arguments (scripting support)

• Find Tagcrumbs by many filter criteria

• All Resources are supported

• Load Suggestions to help a User create a new Placemark

You can find the gem on http://github.com/tagcrumbs/tagcrumbs_gem.

Installation
sudo gem install tagcrumbs

Code Example

# Find all Placemarks near a location
nearby = Tagcrumbs::Tagcrumb.find(:from => :everybody, :within => 0.55, :latitude => 49, :longitude => 9,
:sort => :distance, :order => :asc, :per_page => 50, :type => :placemark)

puts “A total of #{nearby.total_entries} Tagcrumbs nearby”

nearby.each do |placemark|
puts placemark.name
end

# Create a new Placemark, after OAuth was configured, see Github for more details

placemark = Tagcrumbs::Placemark.new(:name => “Tagcrumbs Gem Test”, :notes => “My Notes”, :tag_list => ‘tag1, tag2’,
:private => true, :latitude => 49.12, :longitude => 9.01, :guess_city => true)

if placemark.save
puts “Saved Placemark and the URL is #{placemark.resource_url}”
else
puts “Could not save Placemark”
end

# More examples on Github

Command line
tagcrumbs -n “Name of Placemark” -N “Notes” -x 9 -y 49.9 # create a Placemark from command line, more parameters available

Your Library here

Contact us if you created a library that you want to share and we will include it in this list.


Posted

in

by

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *