2017 © Pedro Peláez
 

yii2-extension yii2-numverify

A Yii2 extension to use the NumVerify API, which offers a full-featured yet simple RESTful JSON API for national and international phone number validation and information lookup for a total of 232 countries around the world

image

giddyeffects/yii2-numverify

A Yii2 extension to use the NumVerify API, which offers a full-featured yet simple RESTful JSON API for national and international phone number validation and information lookup for a total of 232 countries around the world

  • Wednesday, April 5, 2017
  • by giddyeffects
  • Repository
  • 0 Watchers
  • 0 Stars
  • 1 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Global Phone Number Validation and Information Lookup using Numverify API

A Yii2 extension to use the NumVerify API, which offers a full-featured yet simple RESTful JSON API for national and international phone number validation and information lookup for a total of 232 countries around the world, (*1)

Installation

The preferred way to install this extension is through composer., (*2)

Either run, (*3)

php composer.phar require --prefer-dist "giddyeffects/yii2-numverify":"@dev"

or add, (*4)

"giddyeffects/yii2-numverify": "@dev"

to the require section of your composer.json file., (*5)

Usage

First get an Numverify API key here., (*6)

Once the extension is installed, simply add the following code in your application configuration:, (*7)

return [
    //....
    'components' => [
        //...
        'numverify' => [
            'class' => 'giddyeffects\numverify\Numverify',
            'access_key' => 'YOUR_NUMVERIFY_API_KEY',
        ],
    ],
];

You can now access the extension via \Yii::$app->numverify;, (*8)

For more details refer to the Numverify Documentation., (*9)

Example

$response = \Yii::$app->numverify->verify(4158586273, ['country_code'=>'us']);
//check if there's an error
if ($response->error){
    echo $response->error->info;
}
else{
    if($response->valid=='1'){
        echo "Number '$response->number' is valid.";
        echo "<br>";
        echo "local_format: $response->local_format";
        echo "<br>";
        echo "international_format: $response->international_format";
        echo "<br>";
        echo "country_prefix: $response->country_prefix";
        echo "<br>";
        echo "country_code: $response->country_code";
        echo "<br>";
        echo "country_name: $response->country_name";
        echo "<br>";
        echo "location: $response->location";
        echo "<br>";
        echo "carrier: $response->carrier";
        echo "<br>";
        echo "line_type: $response->line_type";
        echo "<br>";
    }
    else{
        echo "Number given is not valid.";
    }
}

The Versions

05/04 2017

dev-master

9999999-dev

A Yii2 extension to use the NumVerify API, which offers a full-featured yet simple RESTful JSON API for national and international phone number validation and information lookup for a total of 232 countries around the world

  Sources   Download

BSD-3-Clause

The Requires

 

by Gideon Nyaga

extension yii2 numverify yii2-numverify giddyeffects verify number number verify