Set up your Ringcaptcha keys (eg in config/initializers/ringcaptcha.rb):
Ringcaptcha.app_key = '...'
Ringcaptcha.api_key = '...'
Ringcaptcha.secret_key = '...'
Add this line to your application's Gemfile:
gem 'ringcaptcha', :git => 'https://github.com/paolodona/ringcaptcha.git'
And then execute:
$ bundle
response = Ringcaptcha.normalize('353 083 148 0349')
response #=> <Ringcaptcha::Response status="SUCCESS", phone="+353831480348", country="IE", area=nil, block=nil, subscriber=nil, type="MOBILE", carrier="Vodafone">
response.success? #=> true
response.error? #=> false
response.status #=> "SUCCESS"
response.phone #=> "+353831480349"
response.country #=> "IE"
response.area #=> nil
response.block #=> nil
response.subscriber #=> nil
response.type #=> "MOBILE"
response.carrier #=> "Vodafone"
# Step 1 - Get a captcha token
locale = "de"
response = Ringcaptcha.captcha(locale)
response.token # => "31b0332942cc4e274118098f95cba64f8eb413fa"
# Step 2 - Send the PIN code
token = response.token
phone = "+353831480349"
service = "sms"
Ringcaptcha.code(token, phone, service)
# Step 3 - Verify the PIN code
code = "1234"
response = Ringcaptcha.verify(token, code)
response #=> #<Ringcaptcha::Response status="SUCCESS",id="2381555c031619e61b3f81af30445b27a87ae97a", phone="+353831480349", geolocation=1, phone_type="MOBILE", carrier="Vodafone", threat_level="LOW">
If you have multiple application under the same account. You can specify the app_key directly when calling individual calls.
Ringcaptcha.api_key = '...'
Ringcaptcha.secret_key = '...'
my_app_key = "..."
response = Ringcaptcha.captcha(app_key: my_app_key)
Ringcaptcha.code(response.token, "+353831480349", app_key: my_app_key)
code = "1234"
Ringcaptcha.verify(response.token, code, app_key: my_app_key)
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request