API-Intis
view release on metacpan or search on metacpan
API/Intis/README.mkdn view on Meta::CPAN
* requesting lists of databases;
* requesting lists of numbers within particular contact list;
* searching for a particular number in a stop list;
* adding new templates;
* requesting monthly statistics;
* making HLR request;
* HLR request
* receiving HLR request statistics;
* requesting an operatorâs name by phone number;
To begin using our API please [apply](https://go.intistele.com/external/client/register/) for your account at our website where you can get your login and API key.
## Usage
### Configiration
1. Create and/or Edit config file - config.yaml
* login : you login
* APIKey : you API key
2. Set additional options in the hash.
```perl
my %addition_params = (state=> '6546546654');
```
## API
1. use API::Intis
2. Call API with method
API/Intis/README.mkdn view on Meta::CPAN
| add2stop | Adding a number to the blacklist | Base + Additional (phone)|
| add_template | Adding a template | Base + Additional (name, text, override) |
| del_template | Deleting a template | Base + Additional (name) |
| stat_by_month | General statistics for a month | Base + Additional (month) |
| hlr | HLR request | Base + Additional (phone) |
| hlr_stat | Statistics of HLR requests | Base + Additional (from, to) |
| operator | Mobile operator query | Base + Additional (phone, text) |
| incoming | Request for incoming SMS | Base + Additional (date, from, to) |
| prices | Request for prices | Base |
> Base params - login, signature, timestamp. Param login and signature - is is obtained from the configuration file. [Look of configuration](#configiration), timestamp - is obtained automatically.
# AUTHOR
Nick Nomos <nnmos@cpan.org>
# COPYRIGHT AND LICENSE
This software is copyright (c) 2016 by Nick Nomos.
GNU GPL 1991.
API/Intis/lib/API/Intis.pm view on Meta::CPAN
use YAML::Tiny;
use WWW::Mechanize;
use Crypt::SSLeay;
use Digest::Perl::MD5 'md5_hex';
use JSON;
use error_codes;
sub readConfig {
my $conf = YAML::Tiny->read( 'config.yaml' );
return (login => $conf->[0]->{APIconnector}->{login}, APIkey => $conf->[0]->{APIconnector}->{APIkey}, host => $conf->[0]->{APIconnector}->{host});
};
sub build_signature {
my (%params) = @_;
delete $params{host};
my $APIkey = delete $params{APIkey};
my @ssignature;
foreach my $key(sort keys %params){
say "$key => $params{$key}";
push @ssignature, $params{$key};
API/Intis/lib/API/Intis.pm view on Meta::CPAN
};
%config = (%config, %timestamp, %other_params);
} else {
%config = (%config, %timestamp);
};
my @o_formats = ('xml', 'json');
my $request_json; my $request_xml;
foreach my $format (@o_formats) {
$config{return} = $format;
my $signature = &build_signature(%config);
my $url = "$config{host}$method.php?login=$config{login}&signature=$signature";
while((my $key, my $value) = each %config){
say "$key => $value\n";
next if $key eq 'host' || $key eq 'login' || $key eq 'APIkey';
$url .= "&$key=$value";
};
my $request = $ua->get("$url&return=$format")->decoded_content(charset => 'utf-8', raw => 1);
$request_json = $request if $format eq 'json';
$request_xml = $request if $format eq 'xml';
};
my $r = from_json($request_json);
my @error;
if ($r->{error}) {
@error = &error_codes::get_name_from_code($r->{error});
API/Intis/lib/API/error_codes.pm view on Meta::CPAN
switch ($code // "")
{
# code keys
case "000" { $descr = 'Service unavailable'; }
case "1" { $descr = 'Signature not specified'; }
case "2" { $descr = 'Login not specified'; }
case "3" { $descr = 'Text not specified'; }
case "4" { $descr = 'Phone number not specified'; }
case "5" { $descr = 'Sender not specified'; }
case "6" { $descr = 'Invaild signature'; }
case "7" { $descr = 'Invalid login'; }
case "8" { $descr = 'Invalid sender name'; }
case "9" { $descr = 'Sender name not registered'; }
case "10" { $descr = 'Sender name not approved'; }
case "11" { $descr = 'There are forbidden words in the text'; }
case "12" { $descr = 'Error in SMS sending'; }
case "13" { $descr = 'Phone number is in the stop list. SMS sending to this number is forbidden.'; }
case "14" { $descr = 'There are more than 50 numbers in the request'; }
case "15" { $descr = 'List not specified'; }
case "16" { $descr = 'Invalid phone number'; }
case "17" { $descr = 'SMS ID not specified'; }
( run in 1.184 second using v1.01-cache-2.11-cpan-49f99fa48dc )