R
R
Ruslan Fedoseev2015-11-06 23:34:54
Perl
Ruslan Fedoseev, 2015-11-06 23:34:54

Need advice from someone who has worked with the Regru::API perl module?

Need advice from someone who has worked with this module.
In general, the question is quite simple, but I can’t figure out how to get to the data.
There is a code.

#!/usr/bin/perl

use Regru::API;
use Data::Dumper;

my $client = Regru::API->new(
   username => "test",
   password => "test"
);

my $params = { show_renew_data => 1, show_update_data => 1};

$resp = $client->domain->get_prices( $params );

if ($resp->is_success) {

 %prices = $resp->get("prices");  ///  А вот как тут правильно дальше - не пойму.

};

Show me how to get to the received prices for domains? Here's how to turn from the received list and get the price of the .ru domain?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Ruslan Fedoseev, 2015-11-07
@martin74ua

Ripped it off myself. Here is a working version, maybe someone will need it

#!/usr/bin/perl
use utf8;
binmode(STDOUT,':utf8');

use Regru::API;
use Data::Dumper;
use JSON;

my $client = Regru::API->new(
   username => "test",
   password => "test"
);

my $params = { show_renew_data => 1, show_update_data => 1};

$resp = $client->domain->get_prices( $params );

if ($resp->is_success) {

 foreach $dom ( keys $resp->answer->{'prices'}) {
 print $dom;
 print "\t";
 $reg_price = $resp->answer->{'prices'}{$dom}{'reg_price'};
 print $reg_price;
 print "\t";
 $retail_reg_price = $resp->answer->{'prices'}{$dom}{'retail_reg_price'};
 print $retail_reg_price;
 print "\n";
 };

};

Well, the display of price elements can and should be made prettier, but anyway it is not necessary - they will not be displayed here. I figured out exactly how to get to the data.
The key - Regru::API::Response->answer - contains the decode_json result of the received response from reg.ru

O
Oleg, 2015-11-07
@hobo-mts

And if you read POD on this module?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question