class="inner-page"
Even though Cognalys RESTful API service supports all platforms and developers can integrate it in any applications of their choice, we are providing integration examples in some platforms here, which will be useful and informative to many developers. Cognalys PHP integration example here given is a standalone contact form which will verify the Mobile number of the user before submitting the form to admin.

The role of Cognalys in this example is :
  • A smart mobile number verification tool.
  • Replacing the traditional CAPTCHA system with a new concept.
  • Avoid spammers as the user needs physical access to the mobile number entered.
  • Avoid ROBOTS which submits the forms automatically.

  • Before downloading any example, we recommend you to watch the demonstration video to get an idea about the proper integration of Cognalys API.

    First Step ( Request missed call )

    Request Example
    // These code snippets use an open-source library. http://unirest.io/php $response = Unirest::get("https://www.cognalys.com/api/v1/otp/?access_token=<YOUR_ACCESS_TOKEN>&app_id=<YOUR_APP_ID>&mobile=<MOBILE_NUMBER_TO_VERIFY>");

    Parameters ( meaning )
  • YOUR_ACCESS_TOKEN : access token which you get from one of your OTP app
  • YOUR_APP_ID : app id which you get from one of your OTP app
  • MOBILE_NUMBER_TO_VERIFY : The mobile number to verify ( should include the country code )

  • RESPONSE if success
    { "status": "success", "keymatch": "KEYMATCH_FOR_VERIFYING", "mobile": "REQUESTED_MOBILE_NUMBER", "otp_start": "STARTING_OF_OTP" }


    keywords ( meaning )
  • KEYMATCH_FOR_VERIFYING : This should be requested when you hit the second API ( Second step )
  • REQUESTED_MOBILE_NUMBER : The mobile number which you requested to verify
  • STARTING_OF_OTP : The first five digits of the cognalys missed call number

  • RESPONSE if Failed
    { "status": "failed", "mobile": "REQUESTED_MOBILE_NUMBER", "errors": { "ERROR_CODE": "ERROR_MESSAGE" } }

    keywords ( meaning )
  • KEYMATCH_FOR_VERIFYING : This should be requested when you hit the second API ( Second step )
  • ERROR_CODE : if there is any errors occured the status will be failed .And you will get a dictionary of ERROR_CODE along with its message . Error codes are explianed Here
  • ERROR_MESSAGE : if there is any errors occured the status will be failed. You will get ERROR_MESSAGE as value of ERROR_CODE


  • Second Step ( Confirm Mobile number )

    Request Example
    // These code snippets use an open-source library. http://unirest.io/php $response = Unirest::get("https://www.cognalys.com/api/v1/otp/confirm/?access_token=<YOUR_ACCESS_TOKEN>&app_id=<YOUR_APP_ID>&otp=<THE_FULL_MISSED_CALL_NUMBER>&keymatch=<THE_KEYMATCH_FROM_FIRST_QUERY>");
    RESPONSE if success
    { "status": "success", "message": "SUCCESS_MESSAGE" }

    keywords ( meaning )
  • SUCCESS_MESSAGE : The message when everything went correct

  • RESPONSE if Failed
    { "status": "failed", "mobile": "REQUESTED_MOBILE_NUMBER", "errors": { "ERROR_CODE": "ERROR_MESSAGE" } }

    keywords ( meaning )
  • KEYMATCH_FOR_VERIFYING : This should be requested when you hit the second API ( Second step )
  • ERROR_CODE : if there is any errors occured the status will be failed .And you will get a dictionary of ERROR_CODE along with its message . Error codes are explianed Here
  • ERROR_MESSAGE : if there is any errors occured the status will be failed. You will get ERROR_MESSAGE as value of ERROR_CODE