TellMyCell Mass Text Message Marketing

Ruby Code Samples For The REST API

The Developer Center @ TellMyCell

Code Samples

Sending SMS Messages

Sends SMS text messages via the short code 88202 to a single phone number or an array of phone numbers.

Code Samples

Ruby - XML
require 'net/https'
require 'uri'
require 'xmlsimple'

url = URI.parse('https://app.tellmycell.com/sending/messages')

#prepare post data
req = Net::HTTP::Post.new(url.path)

req.set_form_data({
    'format'=>'xml',
    'User'=>'winnie', 
    'Password'=>'the-pooh', 
    'PhoneNumbers[0]'=>'2123456785', 
    'PhoneNumbers[1]'=>'2123456786', 
    'Subject'=>'From Winnie', 
    'Message'=>'I am a Bear of Very Little Brain, and long words bother me', 
    'StampToSend'=>'1305582245'
})

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true if url.scheme == "https"  # enable SSL/TLS
http.ca_file = "cacert.pem"
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
http.start {
  http.request(req) {|res|

    print res.body+"\n===================================\n"

    ruObj = XmlSimple.xml_in(res.body, {'ForceArray' => false })
    print 'Status: ' + ruObj['Status'].to_s() + "\n"
    print 'Code: ' + ruObj['Code'].to_s() + "\n"
    case res
    when Net::HTTPSuccess
      print 'Message ID: ' + ruObj['Entry']['ID'].to_s() + "\n"
      print 'Subject: ' + ruObj['Entry']['Subject'].to_s() + "\n"
      print 'Message: ' + ruObj['Entry']['Message'].to_s() + "\n"
      print 'Total Recipients: ' + ruObj['Entry']['RecipientsCount'].to_s() + "\n"
      print 'Credits Charged: ' + ruObj['Entry']['Credits'].to_s() + "\n"
      print 'Time To Send: ' + ruObj['Entry']['StampToSend'].to_s() + "\n"
      if !ruObj['Entry']['PhoneNumbers'].nil?
        numbers = ruObj['Entry']['PhoneNumbers']['PhoneNumber']
        print 'Phone Numbers: ' + (numbers.kind_of?(Array) ? numbers.join(', ') : numbers) + "\n"
      end
      if !ruObj['Entry']['LocalOptOuts'].nil?
        numbers = ruObj['Entry']['LocalOptOuts']['PhoneNumber']
        print 'Locally Opted Out Numbers: '+ (numbers.kind_of?(Array) ? numbers.join(', ') : numbers) + "\n"
      end
      if !ruObj['Entry']['GlobalOptOuts'].nil?
        numbers = ruObj['Entry']['GlobalOptOuts']['PhoneNumber']
        print 'Globally Opted Out Numbers: '+ (numbers.kind_of?(Array) ? numbers.join(', ') : numbers) + "\n"
      end
    else
      if !ruObj['Errors'].nil?
        errors = ruObj['Errors']['Error']
        print 'Errors: '+ (errors.kind_of?(Array) ? errors.join(', ') : errors) + "\n"
      end
    end
  
  }
}

                      
Ruby - JSON
require 'net/https'
require 'uri'
require 'json'

url = URI.parse('https://app.tellmycell.com/sending/messages')

#prepare post data
req = Net::HTTP::Post.new(url.path)

req.set_form_data({
    'format'=>'json',
    'User'=>'winnie', 
    'Password'=>'the-pooh', 
    'PhoneNumbers[0]'=>'2123456785', 
    'PhoneNumbers[1]'=>'2123456786', 
    'Subject'=>'From Winnie', 
    'Message'=>'I am a Bear of Very Little Brain, and long words bother me', 
    'StampToSend'=>'1305582245'
})

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true if url.scheme == "https"  # enable SSL/TLS
http.ca_file = "cacert.pem"
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
http.start {
  http.request(req) {|res|

    print res.body+"\n===================================\n"
    ruObj = JSON.parse(res.body)
    print 'Status: ' + ruObj['Response']['Status'].to_s() + "\n"
    print 'Code: ' + ruObj['Response']['Code'].to_s() + "\n"
    case res
    when Net::HTTPSuccess
      print 'Message ID: ' + ruObj['Response']['Entry']['ID'].to_s() + "\n"
      print 'Subject: ' + ruObj['Response']['Entry']['Subject'].to_s() + "\n"
      print 'Message: ' + ruObj['Response']['Entry']['Message'].to_s() + "\n"
      print 'Total Recipients: ' + ruObj['Response']['Entry']['RecipientsCount'].to_s() + "\n"
      print 'Credits Charged: ' + ruObj['Response']['Entry']['Credits'].to_s() + "\n"
      print 'Time To Send: ' + ruObj['Response']['Entry']['StampToSend'].to_s() + "\n"
      if !ruObj['Response']['Entry']['PhoneNumbers'].nil?
        print 'Phone Numbers: ' + ruObj['Response']['Entry']['PhoneNumbers'].join(', ') + "\n"
      end
      if !ruObj['Response']['Entry']['LocalOptOuts'].nil?
        print 'Locally Opted Out Numbers: ' + ruObj['Response']['Entry']['LocalOptOuts'].join(', ') + "\n"
      end
      if !ruObj['Response']['Entry']['GlobalOptOuts'].nil?
        print 'Globally Opted Out Numbers: ' + ruObj['Response']['Entry']['GlobalOptOuts'].join(', ') + "\n"
      end
    else
      if !ruObj['Response']['Errors'].nil?
        print 'Errors: ' + ruObj['Response']['Errors'].join(', ') + "\n"
      end
    end
  }
}

                      




Check Keyword Availability

Check whether a Keyword is available to rent on TellMyCell's short code.

Code Samples

Ruby - XML
require 'net/https'
require 'uri'
require 'xmlsimple'

url = URI.parse('https://app.tellmycell.com')

#prepare post data
req = Net::HTTP::Get.new('/keywords/new?format=xml&Keyword=honey&User=winnie&Password=the-pooh')

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true if url.scheme == "https"  # enable SSL/TLS
http.ca_file = "cacert.pem"
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
http.start {
  http.request(req) {|res|

    print res.body+"\n===================================\n"

    ruObj = XmlSimple.xml_in(res.body, {'ForceArray' => false })

    print 'Status: ' + ruObj['Status'].to_s() + "\n"
    print 'Code: ' + ruObj['Code'].to_s() + "\n"
    case res
    when Net::HTTPSuccess
      print 'Keyword: ' + ruObj['Entry']['Keyword'].to_s() + "\n"
      print 'Availability: ' + ruObj['Entry']['Available'].to_s() + "\n"
    else
      if !ruObj['Errors'].nil?
        errors = ruObj['Errors']['Error']
        print 'Errors: '+ (errors.kind_of?(Array) ? errors.join(', ') : errors) + "\n"
      end
    end

  }
}

                      
Ruby - JSON
require 'net/https'
require 'uri'
require 'json'

url = URI.parse('https://app.tellmycell.com')

req = Net::HTTP::Get.new('/keywords/new?format=json&Keyword=honey&User=winnie&Password=the-pooh')

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true if url.scheme == "https"  # enable SSL/TLS
http.ca_file = "cacert.pem"
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
http.start {
  http.request(req) {|res|

    print res.body+"\n===================================\n"

    ruObj = JSON.parse(res.body)

    print 'Status: ' + ruObj['Response']['Status'].to_s() + "\n"
    print 'Code: ' + ruObj['Response']['Code'].to_s() + "\n"
    case res
    when Net::HTTPSuccess
      print 'Keyword: ' + ruObj['Response']['Entry']['Keyword'].to_s() + "\n"
      print 'Availability: ' + ruObj['Response']['Entry']['Available'].to_s() + "\n"
    else
      if !ruObj['Response']['Errors'].nil?
        print 'Errors: ' + ruObj['Response']['Errors'].join(', ') + "\n"
      end
    end

  }
}
                      




Rent Keyword

Rents a Keyword for use on TellMyCell's short code. You may rent a Keyword using a credit card you have stored in your TellMyCell account, or you may pass credit card details when you call the API.

Code Samples - Stored Card

Ruby - XML
require 'net/https'
require 'uri'
require 'xmlsimple'

url = URI.parse('https://app.tellmycell.com/keywords')

#prepare post data
req = Net::HTTP::Post.new(url.path)

req.set_form_data({
    'format'=>'xml',
    'User'=>'demo', 
    'Password'=>'texting121212', 
    'Keyword'  => 'honey',
    'StoredCreditCard' => '1111'
})

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true if url.scheme == "https"  # enable SSL/TLS
http.ca_file = "cacert.pem"
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
http.start {
  http.request(req) {|res|

    print res.body+"\n===================================\n"

    ruObj = XmlSimple.xml_in(res.body, {'ForceArray' => false })

    print 'Status: ' + ruObj['Status'].to_s() + "\n"
    print 'Code: ' + ruObj['Code'].to_s() + "\n"
    case res
    when Net::HTTPSuccess
      print 'Keyword ID: ' + ruObj['Entry']['ID'].to_s() + "\n"
      print 'Keyword: ' + ruObj['Entry']['Keyword'].to_s() + "\n"
      print 'Is double opt-in enabled: ' + ruObj['Entry']['EnableDoubleOptIn'].to_s() + "\n"
      print 'Confirm message: ' + ruObj['Entry']['ConfirmMessage'].to_s() + "\n"
      print 'Join message: ' + ruObj['Entry']['JoinMessage'].to_s() + "\n"
      print 'Forward email: ' + ruObj['Entry']['ForwardEmail'].to_s() + "\n"
      print 'Forward url: ' + ruObj['Entry']['ForwardUrl'].to_s() + "\n"
      if !ruObj['Entry']['ContactGroupIDs'].nil?
        groups = ruObj['Entry']['ContactGroupIDs']['Group']
        print 'Groups: '+ (groups.kind_of?(Array) ? groups.join(', ') : groups) + "\n"
      end
    else
      if !ruObj['Errors'].nil?
        errors = ruObj['Errors']['Error']
        print 'Errors: '+ (errors.kind_of?(Array) ? errors.join(', ') : errors) + "\n"
      end
    end

  }
}

                      
Ruby - JSON

require 'net/https'
require 'uri'
require 'json'

url = URI.parse('https://app.tellmycell.com/keywords')

#prepare post data
req = Net::HTTP::Post.new(url.path)

req.set_form_data({
    'format'=>'json',
    'User'=>'demo', 
    'Password'=>'texting121212', 
    'Keyword'  => 'honey',
    'StoredCreditCard' => '1111'

})

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true if url.scheme == "https"  # enable SSL/TLS
http.ca_file = "cacert.pem"
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
http.start {
  http.request(req) {|res|

    print res.body+"\n===================================\n"

    ruObj = JSON.parse(res.body)

    print 'Status: ' + ruObj['Response']['Status'].to_s() + "\n"
    print 'Code: ' + ruObj['Response']['Code'].to_s() + "\n"
    case res
    when Net::HTTPSuccess
      print 'Keyword ID: ' + ruObj['Response']['Entry']['ID'].to_s() + "\n"
      print 'Keyword: ' + ruObj['Response']['Entry']['Keyword'].to_s() + "\n"
      print 'Is double opt-in enabled: ' + ruObj['Response']['Entry']['EnableDoubleOptIn'].to_s() + "\n"
      print 'Confirm message: ' + ruObj['Response']['Entry']['ConfirmMessage'].to_s() + "\n"
      print 'Join message: ' + ruObj['Response']['Entry']['JoinMessage'].to_s() + "\n"
      print 'Forward email: ' + ruObj['Response']['Entry']['ForwardEmail'].to_s() + "\n"
      print 'Forward url: ' + ruObj['Response']['Entry']['ForwardUrl'].to_s() + "\n"
      print 'Groups: ' + ruObj['Response']['Entry']['ContactGroupIDs'].join(', ') + "\n"
    else
      if !ruObj['Response']['Errors'].nil?
        print 'Errors: ' + ruObj['Response']['Errors'].join(', ') + "\n"
      end
    end

  }
}


                      

Code Samples - Non-Stored Card

Ruby - XML
require 'net/https'
require 'uri'
require 'xmlsimple'

url = URI.parse('https://app.tellmycell.com/keywords')

#prepare post data
req = Net::HTTP::Post.new(url.path)

req.set_form_data({
    'format'=>'xml',
    'User'=>'winnie', 
    'Password'=>'the-pooh', 
    'Keyword'  => 'honey',
    'FirstName'        => 'Winnie',
    'LastName'         => 'The Pooh',
    'Street'           => 'Hollow tree, under the name of Mr. Sanders',
    'City'             => 'Hundred Acre Woods',
    'State'            => 'New York',
    'Zip'              => '12345',
    'Country'          => 'US',
    'CreditCardTypeID' => 'Visa',
    'Number'           => '4111111111111111',
    'SecurityCode'     => '123',
    'ExpirationMonth'  => '10',
    'ExpirationYear'   => '2017'

})

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true if url.scheme == "https"  # enable SSL/TLS
http.ca_file = "cacert.pem"
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
http.start {
  http.request(req) {|res|

    print res.body+"\n===================================\n"

    ruObj = XmlSimple.xml_in(res.body, {'ForceArray' => false })

    print 'Status: ' + ruObj['Status'].to_s() + "\n"
    print 'Code: ' + ruObj['Code'].to_s() + "\n"
    case res
    when Net::HTTPSuccess
      print 'Keyword ID: ' + ruObj['Entry']['ID'].to_s() + "\n"
      print 'Keyword: ' + ruObj['Entry']['Keyword'].to_s() + "\n"
      print 'Is double opt-in enabled: ' + ruObj['Entry']['EnableDoubleOptIn'].to_s() + "\n"
      print 'Confirm message: ' + ruObj['Entry']['ConfirmMessage'].to_s() + "\n"
      print 'Join message: ' + ruObj['Entry']['JoinMessage'].to_s() + "\n"
      print 'Forward email: ' + ruObj['Entry']['ForwardEmail'].to_s() + "\n"
      print 'Forward url: ' + ruObj['Entry']['ForwardUrl'].to_s() + "\n"
      if !ruObj['Entry']['ContactGroupIDs'].nil?
        groups = ruObj['Entry']['ContactGroupIDs']['Group']
        print 'Groups: '+ (groups.kind_of?(Array) ? groups.join(', ') : groups) + "\n"
      end
    else
      if !ruObj['Errors'].nil?
        errors = ruObj['Errors']['Error']
        print 'Errors: '+ (errors.kind_of?(Array) ? errors.join(', ') : errors) + "\n"
      end
    end

  }
}

                      
Ruby - JSON

require 'net/https'
require 'uri'
require 'json'

url = URI.parse('https://app.tellmycell.com/keywords')

#prepare post data
req = Net::HTTP::Post.new(url.path)

req.set_form_data({
    'format'=>'json',
    'User'=>'winnie', 
    'Password'=>'the-pooh', 
    'Keyword'  => 'honey',
    'FirstName'        => 'Winnie',
    'LastName'         => 'The Pooh',
    'Street'           => 'Hollow tree, under the name of Mr. Sanders',
    'City'             => 'Hundred Acre Woods',
    'State'            => 'New York',
    'Zip'              => '12345',
    'Country'          => 'US',
    'CreditCardTypeID' => 'Visa',
    'Number'           => '4111111111111111',
    'SecurityCode'     => '123',
    'ExpirationMonth'  => '10',
    'ExpirationYear'   => '2017'

})

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true if url.scheme == "https"  # enable SSL/TLS
http.ca_file = "cacert.pem"
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
http.start {
  http.request(req) {|res|

    print res.body+"\n===================================\n"

    ruObj = JSON.parse(res.body)

    print 'Status: ' + ruObj['Response']['Status'].to_s() + "\n"
    print 'Code: ' + ruObj['Response']['Code'].to_s() + "\n"
    case res
    when Net::HTTPSuccess
      print 'Keyword ID: ' + ruObj['Response']['Entry']['ID'].to_s() + "\n"
      print 'Keyword: ' + ruObj['Response']['Entry']['Keyword'].to_s() + "\n"
      print 'Is double opt-in enabled: ' + ruObj['Response']['Entry']['EnableDoubleOptIn'].to_s() + "\n"
      print 'Confirm message: ' + ruObj['Response']['Entry']['ConfirmMessage'].to_s() + "\n"
      print 'Join message: ' + ruObj['Response']['Entry']['JoinMessage'].to_s() + "\n"
      print 'Forward email: ' + ruObj['Response']['Entry']['ForwardEmail'].to_s() + "\n"
      print 'Forward url: ' + ruObj['Response']['Entry']['ForwardUrl'].to_s() + "\n"
      print 'Groups: ' + ruObj['Response']['Entry']['ContactGroupIDs'].join(', ') + "\n"
    else
      if !ruObj['Response']['Errors'].nil?
        print 'Errors: ' + ruObj['Response']['Errors'].join(', ') + "\n"
      end
    end

  }
}

                      




Setup A Keyword

Configures an active Keyword for use on TellMyCell's short code.

Code Samples

Ruby - XML
require 'net/https'
require 'uri'
require 'xmlsimple'

url = URI.parse('https://app.tellmycell.com/keywords/honey')

#prepare post data
req = Net::HTTP::Post.new(url.path)

req.set_form_data({
    'format'=>'xml',
    'User'=>'winnie', 
    'Password'=>'the-pooh', 
    'EnableDoubleOptIn' => 1,
    'ConfirmMessage'    => 'Reply Y to join our sweetest list',
    'JoinMessage'       => 'The only reason for being a bee that I know of, is to make honey. And the only reason for making honey, is so as I can eat it.',
    'ForwardEmail'      => 'honey@bear-alliance.co.uk',
    'ForwardUrl'        => 'http://bear-alliance.co.uk/honey-donations/',
    'ContactGroupIDs[0]'   => 'honey',
    'ContactGroupIDs[1]'   => 'lovers'
})

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true if url.scheme == "https"  # enable SSL/TLS
http.ca_file = "cacert.pem"
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
http.start {
  http.request(req) {|res|

    print res.body+"\n===================================\n"

    ruObj = XmlSimple.xml_in(res.body, {'ForceArray' => false })

    print 'Status: ' + ruObj['Status'].to_s() + "\n"
    print 'Code: ' + ruObj['Code'].to_s() + "\n"
    case res
    when Net::HTTPSuccess
      print 'Keyword ID: ' + ruObj['Entry']['ID'].to_s() + "\n"
      print 'Keyword: ' + ruObj['Entry']['Keyword'].to_s() + "\n"
      print 'Is double opt-in enabled: ' + ruObj['Entry']['EnableDoubleOptIn'].to_s() + "\n"
      print 'Confirm message: ' + ruObj['Entry']['ConfirmMessage'].to_s() + "\n"
      print 'Join message: ' + ruObj['Entry']['JoinMessage'].to_s() + "\n"
      print 'Forward email: ' + ruObj['Entry']['ForwardEmail'].to_s() + "\n"
      print 'Forward url: ' + ruObj['Entry']['ForwardUrl'].to_s() + "\n"
      if !ruObj['Entry']['ContactGroupIDs'].nil?
        groups = ruObj['Entry']['ContactGroupIDs']['Group']
        print 'Groups: '+ (groups.kind_of?(Array) ? groups.join(', ') : groups) + "\n"
      end
    else
      if !ruObj['Errors'].nil?
        errors = ruObj['Errors']['Error']
        print 'Errors: '+ (errors.kind_of?(Array) ? errors.join(', ') : errors) + "\n"
      end
    end

  }
}
                      
Ruby - JSON

require 'net/https'
require 'uri'
require 'json'

url = URI.parse('https://app.tellmycell.com/keywords/honey')

#prepare post data
req = Net::HTTP::Post.new(url.path)

req.set_form_data({
    'format'=>'json',
    'User'=>'winnie', 
    'Password'=>'the-pooh', 
    'EnableDoubleOptIn' => 1,
    'ConfirmMessage'    => 'Reply Y to join our sweetest list',
    'JoinMessage'       => 'The only reason for being a bee that I know of, is to make honey. And the only reason for making honey, is so as I can eat it.',
    'ForwardEmail'      => 'honey@bear-alliance.co.uk',
    'ForwardUrl'        => 'http://bear-alliance.co.uk/honey-donations/',
    'ContactGroupIDs[0]'   => 'honey',
    'ContactGroupIDs[1]'   => 'lovers'
})

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true if url.scheme == "https"  # enable SSL/TLS
http.ca_file = "cacert.pem"
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
http.start {
  http.request(req) {|res|

    print res.body+"\n===================================\n"

    ruObj = JSON.parse(res.body)

    print 'Status: ' + ruObj['Response']['Status'].to_s() + "\n"
    print 'Code: ' + ruObj['Response']['Code'].to_s() + "\n"
    case res
    when Net::HTTPSuccess
      print 'Keyword ID: ' + ruObj['Response']['Entry']['ID'].to_s() + "\n"
      print 'Keyword: ' + ruObj['Response']['Entry']['Keyword'].to_s() + "\n"
      print 'Is double opt-in enabled: ' + ruObj['Response']['Entry']['EnableDoubleOptIn'].to_s() + "\n"
      print 'Confirm message: ' + ruObj['Response']['Entry']['ConfirmMessage'].to_s() + "\n"
      print 'Join message: ' + ruObj['Response']['Entry']['JoinMessage'].to_s() + "\n"
      print 'Forward email: ' + ruObj['Response']['Entry']['ForwardEmail'].to_s() + "\n"
      print 'Forward url: ' + ruObj['Response']['Entry']['ForwardUrl'].to_s() + "\n"
      print 'Groups: ' + ruObj['Response']['Entry']['ContactGroupIDs'].join(', ') + "\n"
    else
      if !ruObj['Response']['Errors'].nil?
        print 'Errors: ' + ruObj['Response']['Errors'].join(', ') + "\n"
      end
    end

  }
}

                      




Cancel A Keyword

Cancels an active Keyword on TellMyCell's short code.

Code Samples

Ruby - XML
require 'net/https'
require 'uri'
require 'xmlsimple'

url = URI.parse('https://app.tellmycell.com/keywords/honey')

#prepare post data
req = Net::HTTP::Post.new(url.path)

req.set_form_data({
    'format'=>'xml',
    '_method'=>'DELETE',
    'User'=>'winnie', 
    'Password'=>'the-pooh', 
})

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true if url.scheme == "https"  # enable SSL/TLS
http.ca_file = "cacert.pem"
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
http.start {
  http.request(req) {|res|

    case res
    when Net::HTTPSuccess
      print "Success!"
    else
      print res.body+"\n===================================\n"

      ruObj = XmlSimple.xml_in(res.body, {'ForceArray' => false })

      print 'Status: ' + ruObj['Status'].to_s() + "\n"
      if !ruObj['Errors'].nil?
        errors = ruObj['Errors']['Error']
        print 'Errors: '+ (errors.kind_of?(Array) ? errors.join(', ') : errors) + "\n"
      end
   end

  }
}

                      
Ruby - JSON
require 'net/https'
require 'uri'
require 'json'

url = URI.parse('https://app.tellmycell.com/keywords/honey')

#prepare post data
req = Net::HTTP::Post.new(url.path)

req.set_form_data({
    'format'=>'json',
    '_method'=>'DELETE',
    'User'=>'winnie', 
    'Password'=>'the-pooh', 
})

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true if url.scheme == "https"  # enable SSL/TLS
http.ca_file = "cacert.pem"
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
http.start {
  http.request(req) {|res|
    case res
    when Net::HTTPSuccess
      print "Success!"
    else
      print res.body+"\n===================================\n"

      ruObj = JSON.parse(res.body)

      print 'Status: ' + ruObj['Response']['Status'].to_s() + "\n"
      if !ruObj['Response']['Errors'].nil?
        print 'Errors: ' + ruObj['Response']['Errors'].join(', ') + "\n"
      end
    end

  }
}

                      




Check Credit Balance

Checks credit balances on your account.

Code Samples

Ruby - XML
require 'net/https'
require 'uri'
require 'xmlsimple'

url = URI.parse('https://app.tellmycell.com')

#prepare post data
req = Net::HTTP::Get.new('/billing/credits/get?format=xml&User=winnie&Password=the-pooh')

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true if url.scheme == "https"  # enable SSL/TLS
http.ca_file = "cacert.pem"
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
http.start {
  http.request(req) {|res|

    print res.body+"\n===================================\n"

    ruObj = XmlSimple.xml_in(res.body, {'ForceArray' => false })

    print 'Status: ' + ruObj['Status'].to_s() + "\n"
    print 'Code: ' + ruObj['Code'].to_s() + "\n"
    case res
    when Net::HTTPSuccess
      print 'Plan credits: ' + ruObj['Entry']['PlanCredits'].to_s() + "\n"
      print 'Anytime credits: ' + ruObj['Entry']['AnytimeCredits'].to_s() + "\n"
      print 'Total: ' + ruObj['Entry']['TotalCredits'].to_s() + "\n"
    else
      if !ruObj['Errors'].nil?
        errors = ruObj['Errors']['Error']
        print 'Errors: '+ (errors.kind_of?(Array) ? errors.join(', ') : errors) + "\n"
      end
    end

  }
}

                      
Ruby - JSON
require 'net/https'
require 'uri'
require 'json'

url = URI.parse('https://app.tellmycell.com')

#prepare post data
req = Net::HTTP::Get.new('/billing/credits/get?format=json&User=winnie&Password=the-pooh')

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true if url.scheme == "https"  # enable SSL/TLS
http.ca_file = "cacert.pem"
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
http.start {
  http.request(req) {|res|

    print res.body+"\n===================================\n"

    ruObj = JSON.parse(res.body)

    print 'Status: ' + ruObj['Response']['Status'].to_s() + "\n"
    print 'Code: ' + ruObj['Response']['Code'].to_s() + "\n"
    case res
    when Net::HTTPSuccess
        print 'Plan credits: ' + ruObj['Response']['Entry']['PlanCredits'].to_s() + "\n"
        print 'Anytime credits: ' + ruObj['Response']['Entry']['AnytimeCredits'].to_s() + "\n"
        print 'Total: ' + ruObj['Response']['Entry']['TotalCredits'].to_s() + "\n"
    else
      if !ruObj['Response']['Errors'].nil?
        print 'Errors: ' + ruObj['Response']['Errors'].join(', ') + "\n"
      end
    end

  }
}

                      




Buy Credits

Buys more credits for your account. You may purchase credits using a credit card you have stored in your TellMyCell account, or you may pass credit card details when you call the API.

Code Samples - Stored Card

Ruby - XML
require 'net/https'
require 'uri'
require 'xmlsimple'

url = URI.parse('https://app.tellmycell.com/billing/credits')

#prepare post data
req = Net::HTTP::Post.new(url.path)

req.set_form_data({
    'format'=>'xml',
    'User'=>'demo', 
    'Password'=>'texting121212', 
    'NumberOfCredits'  => '1000',
    'CouponCode'       => 'honey2011',
    'StoredCreditCard' => '1111'
})

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true if url.scheme == "https"  # enable SSL/TLS
http.ca_file = "cacert.pem"
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
http.start {
  http.request(req) {|res|

    print res.body+"\n===================================\n"
    if res.body.length > 0
      ruObj = XmlSimple.xml_in(res.body, {'ForceArray' => false })
      print 'Status: ' + ruObj['Status'].to_s() + "\n"
      print 'Code: ' + ruObj['Code'].to_s() + "\n"
      case res
      when Net::HTTPSuccess
          print 'Credits purchased: ' + ruObj['Entry']['BoughtCredits'].to_s() + "\n"
          print 'Amount charged: ' + ruObj['Entry']['Amount'].to_s() + "\n"
          print 'Discount: ' + ruObj['Entry']['Discount'].to_s() + "\n"
          print 'Plan credits: ' + ruObj['Entry']['PlanCredits'].to_s() + "\n"
          print 'Anytime credits: ' + ruObj['Entry']['AnytimeCredits'].to_s() + "\n"
          print 'Total: ' + ruObj['Entry']['TotalCredits'].to_s() + "\n"
      else
        if !ruObj['Errors'].nil?
          errors = ruObj['Errors']['Error']
          print 'Errors: '+ (errors.kind_of?(Array) ? errors.join(', ') : errors) + "\n"
        end
      end
    end

  }
}


                      
Ruby - JSON
require 'net/https'
require 'uri'
require 'json'

url = URI.parse('https://app.tellmycell.com/billing/credits')

#prepare post data
req = Net::HTTP::Post.new(url.path)

req.set_form_data({
    'format'=>'json',
    'User'=>'demo', 
    'Password'=>'texting121212', 
    'NumberOfCredits'  => '1000',
    'CouponCode'       => 'honey2011',
    'StoredCreditCard' => '1111'
})

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true if url.scheme == "https"  # enable SSL/TLS
http.ca_file = "cacert.pem"
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
http.start {
  http.request(req) {|res|

    print res.body+"\n===================================\n"

    if res.body.length > 0
      ruObj = JSON.parse(res.body)
      print 'Status: ' + ruObj['Response']['Status'].to_s() + "\n"
      print 'Code: ' + ruObj['Response']['Code'].to_s() + "\n"
      case res
      when Net::HTTPSuccess
        print 'Credits purchased: ' + ruObj['Response']['Entry']['BoughtCredits'].to_s() + "\n"
        print 'Amount charged: ' + ruObj['Response']['Entry']['Amount'].to_s() + "\n"
        print 'Discount: ' + ruObj['Response']['Entry']['Discount'].to_s() + "\n"
        print 'Plan credits: ' + ruObj['Response']['Entry']['PlanCredits'].to_s() + "\n"
        print 'Anytime credits: ' + ruObj['Response']['Entry']['AnytimeCredits'].to_s() + "\n"
        print 'Total: ' + ruObj['Response']['Entry']['TotalCredits'].to_s() + "\n"
      else
        if !ruObj['Response']['Errors'].nil?
          print 'Errors: ' + ruObj['Response']['Errors'].join(', ') + "\n"
        end
      end
    end

  }
}
                      

Code Samples - Non-Stored Card

Ruby - XML
require 'net/https'
require 'uri'
require 'xmlsimple'

url = URI.parse('https://app.tellmycell.com/billing/credits')

#prepare post data
req = Net::HTTP::Post.new(url.path)

req.set_form_data({
    'format'=>'xml',
    'User'=>'winnie', 
    'Password'=>'the-pooh', 
    'NumberOfCredits'  => '1000',
    'CouponCode'       => 'honey2011',
    'FirstName'        => 'Winnie',
    'LastName'         => 'The Pooh',
    'Street'           => 'Hollow tree, under the name of Mr. Sanders',
    'City'             => 'Hundred Acre Woods',
    'State'            => 'New York',
    'Zip'              => '12345',
    'Country'          => 'US',
    'CreditCardTypeID' => 'Visa',
    'Number'           => '4111111111111111',
    'SecurityCode'     => '123',
    'ExpirationMonth'  => '10',
    'ExpirationYear'   => '2017'
})

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true if url.scheme == "https"  # enable SSL/TLS
http.ca_file = "cacert.pem"
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
http.start {
  http.request(req) {|res|

    print res.body+"\n===================================\n"
    if res.body.length > 0
      ruObj = XmlSimple.xml_in(res.body, {'ForceArray' => false })
      print 'Status: ' + ruObj['Status'].to_s() + "\n"
      print 'Code: ' + ruObj['Code'].to_s() + "\n"
      case res
      when Net::HTTPSuccess
          print 'Credits purchased: ' + ruObj['Entry']['BoughtCredits'].to_s() + "\n"
          print 'Amount charged: ' + ruObj['Entry']['Amount'].to_s() + "\n"
          print 'Discount: ' + ruObj['Entry']['Discount'].to_s() + "\n"
          print 'Plan credits: ' + ruObj['Entry']['PlanCredits'].to_s() + "\n"
          print 'Anytime credits: ' + ruObj['Entry']['AnytimeCredits'].to_s() + "\n"
          print 'Total: ' + ruObj['Entry']['TotalCredits'].to_s() + "\n"
      else
        if !ruObj['Errors'].nil?
          errors = ruObj['Errors']['Error']
          print 'Errors: '+ (errors.kind_of?(Array) ? errors.join(', ') : errors) + "\n"
        end
      end
    end

  }
}

                      
Ruby - JSON

require 'net/https'
require 'uri'
require 'json'

url = URI.parse('https://app.tellmycell.com/billing/credits')

#prepare post data
req = Net::HTTP::Post.new(url.path)

req.set_form_data({
    'format'=>'json',
    'User'=>'winnie', 
    'Password'=>'the-pooh', 
    'NumberOfCredits'  => '1000',
    'CouponCode'       => 'honey2011',
    'FirstName'        => 'Winnie',
    'LastName'         => 'The Pooh',
    'Street'           => 'Hollow tree, under the name of Mr. Sanders',
    'City'             => 'Hundred Acre Woods',
    'State'            => 'New York',
    'Zip'              => '12345',
    'Country'          => 'US',
    'CreditCardTypeID' => 'Visa',
    'Number'           => '4111111111111111',
    'SecurityCode'     => '123',
    'ExpirationMonth'  => '10',
    'ExpirationYear'   => '2017'
})

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true if url.scheme == "https"  # enable SSL/TLS
http.ca_file = "cacert.pem"
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
http.start {
  http.request(req) {|res|

    print res.body+"\n===================================\n"

    if res.body.length > 0
      ruObj = JSON.parse(res.body)
      print 'Status: ' + ruObj['Response']['Status'].to_s() + "\n"
      print 'Code: ' + ruObj['Response']['Code'].to_s() + "\n"
      case res
      when Net::HTTPSuccess
        print 'Credits purchased: ' + ruObj['Response']['Entry']['BoughtCredits'].to_s() + "\n"
        print 'Amount charged: ' + ruObj['Response']['Entry']['Amount'].to_s() + "\n"
        print 'Discount: ' + ruObj['Response']['Entry']['Discount'].to_s() + "\n"
        print 'Plan credits: ' + ruObj['Response']['Entry']['PlanCredits'].to_s() + "\n"
        print 'Anytime credits: ' + ruObj['Response']['Entry']['AnytimeCredits'].to_s() + "\n"
        print 'Total: ' + ruObj['Response']['Entry']['TotalCredits'].to_s() + "\n"
      else
        if !ruObj['Response']['Errors'].nil?
          print 'Errors: ' + ruObj['Response']['Errors'].join(', ') + "\n"
        end
      end
    end

  }
}