The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Net::Pface - Perl extension for pface.ru simple API

SYNOPSIS

    use Modern::Perl;
    use Net::Pface;
    my $obj_pface = Net::Pface->new( id  => $site_id, key => $site_key );
      
    # user authentication
    my $hash = $obj_pface->auth( $sess1, $sess2, $user_ip );
    if ( exists $$hash{'result'} ) {
        my $lnk = $$hash{'result'};
        say $$lnk{'id'}; # if id > 0 then user else guest
        say $$lnk{'dname'};
        say $$lnk{'level'};
        say $$lnk{'lang'};
    }
    else {
        say $$hash{'error'};
    }
    
    # get user data
    $hash = $obj_pface->get( $user_id, 'id', 'phone', 'mail' );
    if ( exists $$hash{'result'} ) {
        my $lnk = $$hash{'result'};
        say $$lnk{'id'};
        say $$lnk{'phone'};
        say $$lnk{'mail'};
    }
    else {
        say $$hash{'error'};
    }

DESCRIPTION

This module is simple API for pface.ru.

Connect to server use your pface site_id and site_key:

  my $obj_pface = Net::Pface->new( id => $site_id, key => $site_key );
  
  keys:
  id         - your site id in pface.ru
  key        - your site secret key in pface.ru
  server     - URL pface.ru server for API, default https://s.pface.ru/
  timeout    - timeout connect, default 10
  agent      - browser name, default 'Net-Pface-' + VERSION_MODULE
  type       - connect type to server, default application/json
  cache_time - cache lifetime, default 300; use 0 that off
  

Then you can use two methods: for user authentication or for get user data:

  - user authentication
    $hash = $obj_pface->auth( $sess1, $sess2, $user_ip );
  
  - get user data
    $hash = $obj_pface->get( $user_id, @fields );

You get $hash{'result'}, if you have success answer.

You get $hash{'error'}, if you have error.

You get true in $hash{'is_cache'}, if answer get from cache.

$hash{'answer'} is pure answer from API server.

EXPORT

None.

SEE ALSO

pface.ru API: http://d.pface.ru/request_basic.html

AUTHOR

Konstantin Titov, <xmolex@cpan.org>

COPYRIGHT AND LICENSE

Copyright (C) 2018 by Konstantin Titov

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.