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

BPTP THE AMAARIO Luxury Project Invest Like Royalty in Sector 37D Gurgaon Dwa...
BPTP THE AMAARIO Luxury Project Invest Like Royalty in Sector 37D Gurgaon Dwa...BPTP THE AMAARIO Luxury Project Invest Like Royalty in Sector 37D Gurgaon Dwa...
BPTP THE AMAARIO Luxury Project Invest Like Royalty in Sector 37D Gurgaon Dwa...
ApartmentWala1
 
MEQ Mainstreet Equity Corp Q2 2024 Investor Presentation
MEQ Mainstreet Equity Corp Q2 2024 Investor PresentationMEQ Mainstreet Equity Corp Q2 2024 Investor Presentation
MEQ Mainstreet Equity Corp Q2 2024 Investor Presentation
MEQ - Mainstreet Equity Corp.
 
9990771857 Call Girls in Dwarka Sector 7 Delhi (Call Girls) Delhi
9990771857 Call Girls in Dwarka Sector 7 Delhi (Call Girls) Delhi9990771857 Call Girls in Dwarka Sector 7 Delhi (Call Girls) Delhi
9990771857 Call Girls in Dwarka Sector 7 Delhi (Call Girls) Delhi
delhimodel235
 
BPTP THE AMAARIO For The Royals Of Tomorrow in Sector 37D Gurgaon Dwarka Expr...
BPTP THE AMAARIO For The Royals Of Tomorrow in Sector 37D Gurgaon Dwarka Expr...BPTP THE AMAARIO For The Royals Of Tomorrow in Sector 37D Gurgaon Dwarka Expr...
BPTP THE AMAARIO For The Royals Of Tomorrow in Sector 37D Gurgaon Dwarka Expr...
ApartmentWala1
 
Call Girls in Anand Vihar Delhi +91 8447779280}Call Girls In Delhi Best in D...
Call Girls in Anand Vihar Delhi +91 8447779280}Call Girls In Delhi Best  in D...Call Girls in Anand Vihar Delhi +91 8447779280}Call Girls In Delhi Best  in D...
Call Girls in Anand Vihar Delhi +91 8447779280}Call Girls In Delhi Best in D...
asmaqueen5
 
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
 
9990771857 Call Girls in Dwarka Sector 3 Delhi (Call Girls) Delhi
9990771857 Call Girls in Dwarka Sector 3 Delhi (Call Girls) Delhi9990771857 Call Girls in Dwarka Sector 3 Delhi (Call Girls) Delhi
9990771857 Call Girls in Dwarka Sector 3 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
 
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
 

Kürzlich hochgeladen (20)

Shapoorji Pallonji Joyville Vista Pune | Spend Your Family Time Together
Shapoorji Pallonji Joyville Vista Pune | Spend Your Family Time TogetherShapoorji Pallonji Joyville Vista Pune | Spend Your Family Time Together
Shapoorji Pallonji Joyville Vista Pune | Spend Your Family Time Together
 
BPTP THE AMAARIO Luxury Project Invest Like Royalty in Sector 37D Gurgaon Dwa...
BPTP THE AMAARIO Luxury Project Invest Like Royalty in Sector 37D Gurgaon Dwa...BPTP THE AMAARIO Luxury Project Invest Like Royalty in Sector 37D Gurgaon Dwa...
BPTP THE AMAARIO Luxury Project Invest Like Royalty in Sector 37D Gurgaon Dwa...
 
Retail Center For Sale - 1019 River St., Belleville, WI
Retail Center For Sale - 1019 River St., Belleville, WIRetail Center For Sale - 1019 River St., Belleville, WI
Retail Center For Sale - 1019 River St., Belleville, WI
 
Greater Vancouver Realtors Statistics Package April 2024
Greater Vancouver Realtors Statistics Package April 2024Greater Vancouver Realtors Statistics Package April 2024
Greater Vancouver Realtors Statistics Package April 2024
 
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)
 
M3M The Line Brochure - Premium Investment Opportunity for Commercial Ventures
M3M The Line Brochure - Premium Investment Opportunity for Commercial VenturesM3M The Line Brochure - Premium Investment Opportunity for Commercial Ventures
M3M The Line Brochure - Premium Investment Opportunity for Commercial Ventures
 
MEQ Mainstreet Equity Corp Q2 2024 Investor Presentation
MEQ Mainstreet Equity Corp Q2 2024 Investor PresentationMEQ Mainstreet Equity Corp Q2 2024 Investor Presentation
MEQ Mainstreet Equity Corp Q2 2024 Investor Presentation
 
Prestige Sancoale Goa Residneces Brochure.pdf
Prestige Sancoale Goa Residneces Brochure.pdfPrestige Sancoale Goa Residneces Brochure.pdf
Prestige Sancoale Goa Residneces Brochure.pdf
 
9990771857 Call Girls in Dwarka Sector 7 Delhi (Call Girls) Delhi
9990771857 Call Girls in Dwarka Sector 7 Delhi (Call Girls) Delhi9990771857 Call Girls in Dwarka Sector 7 Delhi (Call Girls) Delhi
9990771857 Call Girls in Dwarka Sector 7 Delhi (Call Girls) Delhi
 
Premium Villa Projects in Sarjapur Road Bengaluru
Premium Villa Projects in Sarjapur Road BengaluruPremium Villa Projects in Sarjapur Road Bengaluru
Premium Villa Projects in Sarjapur Road Bengaluru
 
BPTP THE AMAARIO For The Royals Of Tomorrow in Sector 37D Gurgaon Dwarka Expr...
BPTP THE AMAARIO For The Royals Of Tomorrow in Sector 37D Gurgaon Dwarka Expr...BPTP THE AMAARIO For The Royals Of Tomorrow in Sector 37D Gurgaon Dwarka Expr...
BPTP THE AMAARIO For The Royals Of Tomorrow in Sector 37D Gurgaon Dwarka Expr...
 
2k Shot Call girls Aiims Delhi 9205541914
2k Shot Call girls Aiims Delhi 92055419142k Shot Call girls Aiims Delhi 9205541914
2k Shot Call girls Aiims Delhi 9205541914
 
Call Girls in Anand Vihar Delhi +91 8447779280}Call Girls In Delhi Best in D...
Call Girls in Anand Vihar Delhi +91 8447779280}Call Girls In Delhi Best  in D...Call Girls in Anand Vihar Delhi +91 8447779280}Call Girls In Delhi Best  in D...
Call Girls in Anand Vihar Delhi +91 8447779280}Call Girls In Delhi Best in D...
 
Enjoy Night ≽ 8448380779 ≼ Call Girls In Iffco Chowk (Gurgaon)
Enjoy Night ≽ 8448380779 ≼ Call Girls In Iffco Chowk (Gurgaon)Enjoy Night ≽ 8448380779 ≼ Call Girls In Iffco Chowk (Gurgaon)
Enjoy Night ≽ 8448380779 ≼ Call Girls In Iffco Chowk (Gurgaon)
 
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
 
David Litt Foreclosure Specialist - Your Partner in Real Estate Success
David Litt Foreclosure Specialist - Your Partner in Real Estate SuccessDavid Litt Foreclosure Specialist - Your Partner in Real Estate Success
David Litt Foreclosure Specialist - Your Partner in Real Estate Success
 
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 in Dwarka Sector 3 Delhi (Call Girls) Delhi
9990771857 Call Girls in Dwarka Sector 3 Delhi (Call Girls) Delhi9990771857 Call Girls in Dwarka Sector 3 Delhi (Call Girls) Delhi
9990771857 Call Girls in Dwarka Sector 3 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
 
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...
 

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