[해외 SMS] nexmo sms verify

Verify API 제공

The Verify API enables you to confirm that you can contact a user at a specific number.

  • Protect against spam, by preventing spammers from creating multiple accounts
  • Monitor suspicious activity, by forcing an account user to verify ownership of a number
  • Reach your users at any time, by ensuring that you have their correct phone number

The general workflow is shown in the following sequence diagram:
flow

Node.js를 사용한 테스트

  1. npm init 초기화
  2. npm install nexmo

  3. nexmo npm 선언

    1
    2
    3
    4
    5
    6
    const Nexmo = require('nexmo');

    const nexmo = new Nexmo({
    apiKey: 'xxxxx',
    apiSecret: 'xxxxx',
    });
  4. code 요청하기

    1
    2
    3
    4
    5
    6
    7
    8
    nexmo.verify.request({
    number: '받을휴대번호',
    brand: 'Nexmo',
    code_length: '4'
    }, (err, result) => {
    console.log(err);
    console.log(result);
    });
  5. 결과확인(첫번째가 정상, 두번째는 중복발생불가)

    1
    2
    3
    4
    5
    6
    7
    8
    { request_id: 'dd0ffecfbab1459bba27cb8fc219cfd2', status: '0' }

    OR

    { request_id: 'dd0ffecfbab1459bba27cb8fc219cfd2',
    status: '10',
    error_text:
    'Concurrent verifications to the same number are not allowed' }
  6. 문자메세지 확인
    sms

  7. code 확인하기(받은 request_id로 요청,문자로 받은 코드4자리)

    1
    2
    3
    4
    5
    6
    nexmo.verify.check({
    request_id: 'dd0ffecfbab1459bba27cb8fc219cfd2',
    code: '0000'
    }, (err, result) => {
    console.log(err ? err : result)
    });
  8. 결과확인

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22

    정상
    { request_id: 'dd0ffecfbab1459bba27cb8fc219cfd2',
    status: '0',
    event_id: '1C0000001295AD96',
    price: '0.10000000',
    currency: 'EUR' }

    OR

    코드번호 불일치
    { request_id: 'dd0ffecfbab1459bba27cb8fc219cfd2',
    status: '16',
    error_text: 'The code provided does not match the expected value' }

    OR

    요청을 찾을수없음
    { status: '6',
    error_text:
    'The Nexmo platform was unable to process this message for the following reason: Request \'dd0ffecfbab1459bba27cb8fc219cfd2\' was not found or it has been verified
    already.' }

verify 자체개발 vs verify api 사용

  • verify 자체 개발시 난수발생(4자리,6자리) and 메모리db에 임시저장 확인시 조회 and 로그 자체기록

  • verify api 사용시 따로 메모리db 구축안하고 돈이 더 들어간다. 성공시 0.1 유로? 비싸다. 그냥 sms보내면 0.04유로
    대신 분석 및 로그조회가 가능하다

analytics

참고사이트

https://developer.nexmo.com/verify/overview