dfhdf

355 views
322 views

Published on

dofjngf

Published in: Real Estate
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
355
On SlideShare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
1
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

dfhdf

  1. 1. require 'net/http' require 'uri' require 'rexml/document' # REQUIRED PARAMETERS. USERNAME = 'administrator@estateportal.co.za' PASSWORD = 'secretstory' URL_NAME = quot;http://www.graphicmail.co.za/api.aspx? Username=#{USERNAME}&Password=#{PASSWORD}quot; URL_NAME_POST = quot;http://www.graphicmail.co.za/api.aspx?quot; class GraphicMail # Connect to GraphicMail using HTTP post/get. class Connector def self.setup_http_get(func) xml_data = Net::HTTP.get(URI.parse(quot;#{URL_NAME}&Function=#{func}quot;)) end def self.setup_http_post(form) res = Net::HTTP.post_form(URI.parse(quot;#{URL_NAME_POST}quot;), form) end end ##*** MANAGE MAILING LIST ****## # Get mailinglists. def self.get_mailinglists xml_data = Connector.setup_http_get('get_mailinglists') ref = XmlSimple.xml_in(xml_data) data_array = ref[quot;mailinglistquot;] return data_array end # Get mailinglists. def self.get_mailinglist(id = '17836') xml_data = Connector.setup_http_get(quot;get_mailinglist&MailinglistID=#{id}quot;) ref = XmlSimple.xml_in(xml_data) data_array = ref[quot;emailquot;] return data_array end # Create mailinglists. def self.post_create_mailinglist(new_mailinglist = 'my mailing list') # create a hash for a new mailing list. form = Hash.new form.merge!({:Username => USERNAME, :Password => PASSWORD, :Function => 'post_create_mailinglist', :NewMailinglist => new_mailinglist }) xml_data = Connector.setup_http_post(form) xml_data.msg
  2. 2. end # Delete Mailinglists. def self.post_delete_mailinglist(mailinglist_id = 123456) # create a hash for a new mailing list. form = Hash.new form.merge!({:Username => USERNAME, :Password => PASSWORD, :Function => 'post_delete_mailinglist', :MailinglistID => mailinglist_id }) xml_data = Connector.setup_http_post(form) xml_data.msg end # Delete Mailinglists. def self.post_rename_mailinglist(mailinglist_id = 123456, new_name = 'MyName') # create a hash for a new mailing list. form = Hash.new form.merge!({:Username => USERNAME, :Password => PASSWORD, :Function => 'post_rename_mailinglist', :MailinglistID => mailinglist_id, :NewName => new_name }) xml_data = Connector.setup_http_post(form) xml_data.msg end ##*** END MANAGE MAILING LIST ****## ##*** MANAGE NEWS LETTER ****## # Get mailinglists. def self.get_newsletter(id = '87341') xml_data = Connector.setup_http_get(quot;get_newsletter&NewsletterID=#{id}&TextVersion=falsequot;) # ref = XmlSimple.xml_in(xml_data) xml_data = xml_data.split(quot;rnquot;).join(quot;quot;) xml_data = xml_data.gsub(/quot;/,''') return xml_data end def self.get_newsletters() xml_data = Connector.setup_http_get(quot;get_newslettersquot;) # ref = XmlSimple.xml_in(xml_data) data_array = ref[quot;newsletterquot;] raise data_array.inspect return data_array
  3. 3. end # Delete Newsletter. def self.post_delete_newsletter(newsletter_id = 123456) # create a hash for a new mailing list. form = Hash.new form.merge!({:Username => USERNAME, :Password => PASSWORD, :Function => 'post_delete_newsletter', :NewsletterID => newsletter_id }) xml_data = Connector.setup_http_post(form) xml_data.msg end # Create Newsletter. def self.post_import_newsletter(letter_name) html_url = 'https://www.estateportal.co.za/about/index' # create a hash for a new mailing list. form = Hash.new form.merge!({:Username => USERNAME, :Password => PASSWORD, :Function => 'post_import_newsletter', :HtmlURL => html_url, :NewExisting => 'New', :NewsletterName => letter_name, :NewsletterID => ' ' }) xml_data = Connector.setup_http_post(form) xml_data.body end # Create Newsletter. def self.post_update_newsletter(letter_name) html_url = 'https://www.estateportal.co.za/about/index' # create a hash for a new mailing list. form = Hash.new form.merge!({:Username => USERNAME, :Password => PASSWORD, :Function => 'post_import_newsletter', :HtmlURL => html_url, :NewExisting => 'Existing', :ReplaceLinks => true, :NewsletterName => letter_name, :NewsletterID => quot;quot;, :ReplaceImages => true, :ReplaceLinks => false, :TextURL => quot;Noquot; }) xml_data = Connector.setup_http_post(form)
  4. 4. xml_data.body end ##*** END MANAGE NEWS LETTER ****## end

×