Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

dfhdf

488 views

Published on

dofjngf

Published in: Real Estate
  • Be the first to comment

  • Be the first to like this

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

×