Programatically adding tags to contacts in Highrise
I have been playing with adding tags to contacts in Highrise programatically. Unfortunately, 37Signals has not added this functionality to the API for Highrise so you have to hack it in. Based on a post on adding contacts, the following code will add a single tag to a contact.
require 'rubygems'
require 'net/http'
contact_id = 12345
connection = Net::HTTP.new("your_account.highrisehq.com")
req = Net::HTTP::Post.new("/parties/#{contact_id}/tags")
req["content-type"] = "application/xml"
req.basic_auth("your_api_token", 'X')
req.set_form_data({"name" => "new_or_existing_tag"}, ";")
response = connection.request(req)
puts response
This will return a bunch of JavaScript that you can ignore.
For comparison, here is the same code using HTTParty. A very nice, easy to use library for interacting with ReST services.
require 'rubygems'
require 'httparty'
class Tag
include HTTParty
base_uri "your_site.highrisehq.com"
basic_auth 'your_api_token', 'X'
def add_tag_to_contact(tag, contact_id)
self.class.post("/parties/#{contact_id}/tags", :query => { :name => tag })
end
end
puts Tag.new.add_tag_to_contact("tag_as_string", "1")
The goal of all this is to create a Highrise API wrapper that includes the ability to manipulate tags. Highrise is great, but the lack of Tags in the API really reduces what you can do with the tool since there is no facility for creating or manipulating lists.
