SlideShare ist ein Scribd-Unternehmen logo
1 von 4
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
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
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)
xml_data.body
 end
 ##*** END MANAGE NEWS LETTER ****##


end

Weitere ähnliche Inhalte

Ähnlich wie dfhdf

Ex[1].3 php db connectivity
Ex[1].3 php db connectivityEx[1].3 php db connectivity
Ex[1].3 php db connectivity
Mouli Chandira
 
Library Website
Library WebsiteLibrary Website
Library Website
gholtron
 
Enterprise workflow with Apps Script
Enterprise workflow with Apps ScriptEnterprise workflow with Apps Script
Enterprise workflow with Apps Script
ccherubino
 

Ähnlich wie dfhdf (20)

Week 12 code
Week 12 codeWeek 12 code
Week 12 code
 
The HyperText Markup Language or HTML is the standard markup language
The HyperText Markup Language or HTML is the standard markup languageThe HyperText Markup Language or HTML is the standard markup language
The HyperText Markup Language or HTML is the standard markup language
 
The Django Book - Chapter 7 forms
The Django Book - Chapter 7 formsThe Django Book - Chapter 7 forms
The Django Book - Chapter 7 forms
 
Ex[1].3 php db connectivity
Ex[1].3 php db connectivityEx[1].3 php db connectivity
Ex[1].3 php db connectivity
 
Framework
FrameworkFramework
Framework
 
Intro to sencha touch
Intro to sencha touchIntro to sencha touch
Intro to sencha touch
 
Library Website
Library WebsiteLibrary Website
Library Website
 
Enterprise workflow with Apps Script
Enterprise workflow with Apps ScriptEnterprise workflow with Apps Script
Enterprise workflow with Apps Script
 
Opensocial Codelab
Opensocial CodelabOpensocial Codelab
Opensocial Codelab
 
javaScriptForms.pptx
javaScriptForms.pptxjavaScriptForms.pptx
javaScriptForms.pptx
 
The Zen of Lithium
The Zen of LithiumThe Zen of Lithium
The Zen of Lithium
 
Form demoinplaywithmysql
Form demoinplaywithmysqlForm demoinplaywithmysql
Form demoinplaywithmysql
 
RubyBarCamp “Полезные gems и plugins”
RubyBarCamp “Полезные gems и plugins”RubyBarCamp “Полезные gems и plugins”
RubyBarCamp “Полезные gems и plugins”
 
Bag Of Tricks From Iusethis
Bag Of Tricks From IusethisBag Of Tricks From Iusethis
Bag Of Tricks From Iusethis
 
What's new in Rails 2?
What's new in Rails 2?What's new in Rails 2?
What's new in Rails 2?
 
Drupal Development (Part 2)
Drupal Development (Part 2)Drupal Development (Part 2)
Drupal Development (Part 2)
 
Rugalytics | Ruby Manor Nov 2008
Rugalytics | Ruby Manor Nov 2008Rugalytics | Ruby Manor Nov 2008
Rugalytics | Ruby Manor Nov 2008
 
Sending E-mail that reaches the destination using PHP
Sending E-mail that reaches the destination using PHPSending E-mail that reaches the destination using PHP
Sending E-mail that reaches the destination using PHP
 
Creating Domain Specific Languages in Python
Creating Domain Specific Languages in PythonCreating Domain Specific Languages in Python
Creating Domain Specific Languages in Python
 
Sencha Touch Intro
Sencha Touch IntroSencha Touch Intro
Sencha Touch Intro
 

Kürzlich hochgeladen

Call Girls In Majnu Ka Tilla (Delhi) ꧁8447779280}@꧂ Escorts Service Delhi
Call Girls In Majnu Ka Tilla (Delhi) ꧁8447779280}@꧂ Escorts Service DelhiCall Girls In Majnu Ka Tilla (Delhi) ꧁8447779280}@꧂ Escorts Service Delhi
Call Girls In Majnu Ka Tilla (Delhi) ꧁8447779280}@꧂ Escorts Service Delhi
asmaqueen5
 
Low Rate Call girls in Sant Nagar{Delhi }8447779280} Service Escorts In South...
Low Rate Call girls in Sant Nagar{Delhi }8447779280} Service Escorts In South...Low Rate Call girls in Sant Nagar{Delhi }8447779280} Service Escorts In South...
Low Rate Call girls in Sant Nagar{Delhi }8447779280} Service Escorts In South...
asmaqueen5
 
9990771857 Call Girls Dwarka Sector 8 Delhi (Call Girls ) Delhi
9990771857 Call Girls  Dwarka Sector 8 Delhi (Call Girls ) Delhi9990771857 Call Girls  Dwarka Sector 8 Delhi (Call Girls ) Delhi
9990771857 Call Girls Dwarka Sector 8 Delhi (Call Girls ) Delhi
delhimodel235
 
Call Girls In Seelampur Delhi ↬8447779280}Seelampur Escorts Service In Delhi...
Call Girls In Seelampur  Delhi ↬8447779280}Seelampur Escorts Service In Delhi...Call Girls In Seelampur  Delhi ↬8447779280}Seelampur Escorts Service In Delhi...
Call Girls In Seelampur Delhi ↬8447779280}Seelampur Escorts Service In Delhi...
asmaqueen5
 
Bptp The Amaario Launch Luxury Project Sector 37D Gurgaon Dwarka Expressway...
Bptp The Amaario Launch  Luxury Project  Sector 37D Gurgaon Dwarka Expressway...Bptp The Amaario Launch  Luxury Project  Sector 37D Gurgaon Dwarka Expressway...
Bptp The Amaario Launch Luxury Project Sector 37D Gurgaon Dwarka Expressway...
ApartmentWala1
 
Call Girls In Krishna Nagar Delhi (Escort)↫8447779280↬@SHOT 1500- NIGHT 5500→...
Call Girls In Krishna Nagar Delhi (Escort)↫8447779280↬@SHOT 1500- NIGHT 5500→...Call Girls In Krishna Nagar Delhi (Escort)↫8447779280↬@SHOT 1500- NIGHT 5500→...
Call Girls In Krishna Nagar Delhi (Escort)↫8447779280↬@SHOT 1500- NIGHT 5500→...
asmaqueen5
 
9990771857 Call Girls in Dwarka Sector 1 Delhi (Call Girls) Delhi
9990771857 Call Girls in Dwarka Sector 1 Delhi (Call Girls) Delhi9990771857 Call Girls in Dwarka Sector 1 Delhi (Call Girls) Delhi
9990771857 Call Girls in Dwarka Sector 1 Delhi (Call Girls) Delhi
delhimodel235
 
9990771857 Call Girls Dwarka Sector 9 Delhi (Call Girls ) Delhi
9990771857 Call Girls Dwarka Sector 9 Delhi (Call Girls ) Delhi9990771857 Call Girls Dwarka Sector 9 Delhi (Call Girls ) Delhi
9990771857 Call Girls Dwarka Sector 9 Delhi (Call Girls ) Delhi
delhimodel235
 
9990771857 Call Girls in Dwarka Sector 6 Delhi (Call Girls) Delhi
9990771857 Call Girls in Dwarka Sector 6 Delhi (Call Girls) Delhi9990771857 Call Girls in Dwarka Sector 6 Delhi (Call Girls) Delhi
9990771857 Call Girls in Dwarka Sector 6 Delhi (Call Girls) Delhi
delhimodel235
 
Cheap Rate ✨➥9711108085▻✨Call Girls In Bhajanpura (Delhi)
Cheap Rate ✨➥9711108085▻✨Call Girls In Bhajanpura (Delhi)Cheap Rate ✨➥9711108085▻✨Call Girls In Bhajanpura (Delhi)
Cheap Rate ✨➥9711108085▻✨Call Girls In Bhajanpura (Delhi)
delhi24hrs1
 
9990771857 Call Girls in Dwarka Sector 07 Delhi (Call Girls) Delhi
9990771857 Call Girls in Dwarka Sector 07 Delhi (Call Girls) Delhi9990771857 Call Girls in Dwarka Sector 07 Delhi (Call Girls) Delhi
9990771857 Call Girls in Dwarka Sector 07 Delhi (Call Girls) Delhi
delhimodel235
 

Kürzlich hochgeladen (20)

Call Girls In Majnu Ka Tilla (Delhi) ꧁8447779280}@꧂ Escorts Service Delhi
Call Girls In Majnu Ka Tilla (Delhi) ꧁8447779280}@꧂ Escorts Service DelhiCall Girls In Majnu Ka Tilla (Delhi) ꧁8447779280}@꧂ Escorts Service Delhi
Call Girls In Majnu Ka Tilla (Delhi) ꧁8447779280}@꧂ Escorts Service Delhi
 
Low Rate Call girls in Sant Nagar{Delhi }8447779280} Service Escorts In South...
Low Rate Call girls in Sant Nagar{Delhi }8447779280} Service Escorts In South...Low Rate Call girls in Sant Nagar{Delhi }8447779280} Service Escorts In South...
Low Rate Call girls in Sant Nagar{Delhi }8447779280} Service Escorts In South...
 
9990771857 Call Girls Dwarka Sector 8 Delhi (Call Girls ) Delhi
9990771857 Call Girls  Dwarka Sector 8 Delhi (Call Girls ) Delhi9990771857 Call Girls  Dwarka Sector 8 Delhi (Call Girls ) Delhi
9990771857 Call Girls Dwarka Sector 8 Delhi (Call Girls ) Delhi
 
Call Girls In Seelampur Delhi ↬8447779280}Seelampur Escorts Service In Delhi...
Call Girls In Seelampur  Delhi ↬8447779280}Seelampur Escorts Service In Delhi...Call Girls In Seelampur  Delhi ↬8447779280}Seelampur Escorts Service In Delhi...
Call Girls In Seelampur Delhi ↬8447779280}Seelampur Escorts Service In Delhi...
 
Real Estate Finance and Investments (2019).pdf
Real Estate Finance and Investments (2019).pdfReal Estate Finance and Investments (2019).pdf
Real Estate Finance and Investments (2019).pdf
 
Bptp The Amaario Launch Luxury Project Sector 37D Gurgaon Dwarka Expressway...
Bptp The Amaario Launch  Luxury Project  Sector 37D Gurgaon Dwarka Expressway...Bptp The Amaario Launch  Luxury Project  Sector 37D Gurgaon Dwarka Expressway...
Bptp The Amaario Launch Luxury Project Sector 37D Gurgaon Dwarka Expressway...
 
Kolte Patil Kharadi Pune E Brochure.pdf
Kolte Patil Kharadi Pune E  Brochure.pdfKolte Patil Kharadi Pune E  Brochure.pdf
Kolte Patil Kharadi Pune E Brochure.pdf
 
Call Girls In Krishna Nagar Delhi (Escort)↫8447779280↬@SHOT 1500- NIGHT 5500→...
Call Girls In Krishna Nagar Delhi (Escort)↫8447779280↬@SHOT 1500- NIGHT 5500→...Call Girls In Krishna Nagar Delhi (Escort)↫8447779280↬@SHOT 1500- NIGHT 5500→...
Call Girls In Krishna Nagar Delhi (Escort)↫8447779280↬@SHOT 1500- NIGHT 5500→...
 
Kohinoor Teiko Hinjewadi Phase 2 Pune E-Brochure.pdf
Kohinoor Teiko Hinjewadi Phase 2 Pune  E-Brochure.pdfKohinoor Teiko Hinjewadi Phase 2 Pune  E-Brochure.pdf
Kohinoor Teiko Hinjewadi Phase 2 Pune E-Brochure.pdf
 
SVN Live 5.6.24 Weekly Property Broadcast
SVN Live 5.6.24 Weekly Property BroadcastSVN Live 5.6.24 Weekly Property Broadcast
SVN Live 5.6.24 Weekly Property Broadcast
 
9990771857 Call Girls in Dwarka Sector 1 Delhi (Call Girls) Delhi
9990771857 Call Girls in Dwarka Sector 1 Delhi (Call Girls) Delhi9990771857 Call Girls in Dwarka Sector 1 Delhi (Call Girls) Delhi
9990771857 Call Girls in Dwarka Sector 1 Delhi (Call Girls) Delhi
 
Bridge & Elliot Ladner Floor Plans May 2024.pdf
Bridge & Elliot Ladner Floor Plans May 2024.pdfBridge & Elliot Ladner Floor Plans May 2024.pdf
Bridge & Elliot Ladner Floor Plans May 2024.pdf
 
Enjoy Night ≽ 8448380779 ≼ Call Girls In Huda City Centre (Gurgaon)
Enjoy Night ≽ 8448380779 ≼ Call Girls In Huda City Centre (Gurgaon)Enjoy Night ≽ 8448380779 ≼ Call Girls In Huda City Centre (Gurgaon)
Enjoy Night ≽ 8448380779 ≼ Call Girls In Huda City Centre (Gurgaon)
 
9990771857 Call Girls Dwarka Sector 9 Delhi (Call Girls ) Delhi
9990771857 Call Girls Dwarka Sector 9 Delhi (Call Girls ) Delhi9990771857 Call Girls Dwarka Sector 9 Delhi (Call Girls ) Delhi
9990771857 Call Girls Dwarka Sector 9 Delhi (Call Girls ) Delhi
 
9990771857 Call Girls in Dwarka Sector 6 Delhi (Call Girls) Delhi
9990771857 Call Girls in Dwarka Sector 6 Delhi (Call Girls) Delhi9990771857 Call Girls in Dwarka Sector 6 Delhi (Call Girls) Delhi
9990771857 Call Girls in Dwarka Sector 6 Delhi (Call Girls) Delhi
 
Cheap Rate ✨➥9711108085▻✨Call Girls In Bhajanpura (Delhi)
Cheap Rate ✨➥9711108085▻✨Call Girls In Bhajanpura (Delhi)Cheap Rate ✨➥9711108085▻✨Call Girls In Bhajanpura (Delhi)
Cheap Rate ✨➥9711108085▻✨Call Girls In Bhajanpura (Delhi)
 
Rohan Harita Tathawade Pune Brochure.pdf
Rohan Harita Tathawade Pune Brochure.pdfRohan Harita Tathawade Pune Brochure.pdf
Rohan Harita Tathawade Pune Brochure.pdf
 
9990771857 Call Girls in Dwarka Sector 07 Delhi (Call Girls) Delhi
9990771857 Call Girls in Dwarka Sector 07 Delhi (Call Girls) Delhi9990771857 Call Girls in Dwarka Sector 07 Delhi (Call Girls) Delhi
9990771857 Call Girls in Dwarka Sector 07 Delhi (Call Girls) Delhi
 
The Gale at Godrej Park World Hinjewadi Pune Brochure.pdf
The Gale at Godrej Park World Hinjewadi Pune Brochure.pdfThe Gale at Godrej Park World Hinjewadi Pune Brochure.pdf
The Gale at Godrej Park World Hinjewadi Pune Brochure.pdf
 
2k Shots ≽ 9205541914 ≼ Call Girls In Sainik Farm (Delhi)
2k Shots ≽ 9205541914 ≼ Call Girls In Sainik Farm (Delhi)2k Shots ≽ 9205541914 ≼ Call Girls In Sainik Farm (Delhi)
2k Shots ≽ 9205541914 ≼ Call Girls In Sainik Farm (Delhi)
 

dfhdf

  • 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. 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. 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. xml_data.body end ##*** END MANAGE NEWS LETTER ****## end