Skip to content

Commit

Permalink
Enable XML posting
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom Meier committed Aug 12, 2009
1 parent 3d1a6c3 commit 88ed730
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
45 changes: 45 additions & 0 deletions README.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,51 @@ get logged in Rails log file.

Enjoy!

== Alternative Signup with XML

To submit new leads via xml (useful for inline code submissions to a synced app or via AJAX).
Default root xml element should be :"ffcrm", this is required to ensure the parameters are checked correctly.

On source app :

#Required fields:
#access, do-not-call, first-name, last-name
xml = Builder::XmlMarkup.new
xml.instruct!
xml.ffcrm do
xml.lead do
xml.access "Public" #or Private
xml.address "1234 Sample Address", "nil" => "true"
xml.tag!("alt-email", "", "nil" => "true")
xml.tag!("assigned-to", "", "nil" => "true", "type"=>"integer")
xml.blog "", "nil" => "true"
xml.tag!("campaign-id", "", "nil" => "true", "type"=>"integer")
xml.company "", "nil" => "true"
xml.tag!("do-not-call", "false", "type"=>"boolean")
xml.email "foo.bar@here.com", "nil" => "true"
xml.tag!("first-name", "Foo")
xml.tag!("last-name", "Bar")
xml.mobile "", "nil" => "true"
xml.phone "", "nil" => "true"
xml.tag!("referred-by", "", "nil" => "true")
xml.source "", "nil" => "true"
xml.status "", "nil" => "true"
xml.title "", "nil" => "true"
xml.tag!("user-id", "", "type" => "integer", "nil" => "true")
xml.tag!("uuid", "", "nil" => "true")
end
xml.authorization "password_hash for user in Fat Free CRM"
xml.token "password_salt for user in Fat Free CRM"
end

#Add to fat free CRM
url = URI.parse('http://localhost:3000/leads.xml')
request = Net::HTTP::Post.new(url.path)
request.content_type = 'text/xml'
request.body = xml.target!
response = Net::HTTP.start(url.host, url.port) {|http| http.request(request)}


---
Copyright (c) 2009 by Michael Dvorkin, released under the MIT license.

Expand Down
1 change: 1 addition & 0 deletions lib/crm_web_to_lead.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ def app_before_filter(controller, context = {})
# <input type="hidden" name="token" value="-- password_token here --">

params = controller.params
params.merge!(params[:ffcrm]).delete(:ffcrm) if (controller.request.xhr? || controller.request.headers["CONTENT_TYPE"] == 'text/xml') && params[:ffcrm]
if controller.request.post? && !params[:authorization].blank? && !params[:token].blank?
user = User.find_by_password_hash_and_password_salt(params[:authorization], params[:token])

Expand Down

0 comments on commit 88ed730

Please sign in to comment.