Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/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
https://github.com/giddyeffects/yii2-numverify
information-lookup yii2-extension
Last synced: 6 days ago
JSON representation
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
- Host: GitHub
- URL: https://github.com/giddyeffects/yii2-numverify
- Owner: giddyeffects
- Created: 2017-04-03T00:00:53.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-04-05T10:39:06.000Z (over 7 years ago)
- Last Synced: 2024-10-11T05:21:21.431Z (about 1 month ago)
- Topics: information-lookup, yii2-extension
- Language: PHP
- Size: 3.91 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
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 worldInstallation
------------The preferred way to install this extension is through [composer](http://getcomposer.org/download/).
Either run
```
php composer.phar require --prefer-dist "giddyeffects/yii2-numverify":"@dev"
```or add
```
"giddyeffects/yii2-numverify": "@dev"
```to the require section of your `composer.json` file.
Usage
-----First get an Numverify API key [here](https://numverify.com/product).
Once the extension is installed, simply add the following code in your application configuration:
```php
return [
//....
'components' => [
//...
'numverify' => [
'class' => 'giddyeffects\numverify\Numverify',
'access_key' => 'YOUR_NUMVERIFY_API_KEY',
],
],
];
```
You can now access the extension via ```\Yii::$app->numverify;```For more details refer to the [Numverify Documentation](https://numverify.com/documentation).
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 "
";
echo "local_format: $response->local_format";
echo "
";
echo "international_format: $response->international_format";
echo "
";
echo "country_prefix: $response->country_prefix";
echo "
";
echo "country_code: $response->country_code";
echo "
";
echo "country_name: $response->country_name";
echo "
";
echo "location: $response->location";
echo "
";
echo "carrier: $response->carrier";
echo "
";
echo "line_type: $response->line_type";
echo "
";
}
else{
echo "Number given is not valid.";
}
}
```