Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use Digest::HMAC_SHA1 qw(hmac_sha1 hmac_sha1_hex);
- use LWP::Simple;
- use Data::Dumper;
- use JSON;
- use URI::Escape;
- our $api_key = "061025241049";
- our $api_secret = "88af9526ee967179";
- sub mac($)
- {
- my $url = shift;
- my $z = $url =~ m/[?]/ ? '&' : '?';
- my $r = "${url}${z}api_consumer_key=$api_key";
- my $mac = hmac_sha1_hex($r, $api_secret);
- $r = "$r&api_signature=$mac";
- return $r;
- }
- sub get_movie($)
- {
- my $id = shift;
- my $page = get(mac("https://android-api.csfd.cz/film/$id"));
- my $json = decode_json $page;
- }
- sub get_search($)
- {
- my $q = uri_escape(shift);
- print "escaped: $q\n";
- my $page = get(mac("https://android-api.csfd.cz/search?q=$q"));
- my $json = decode_json $page;
- }
- my $json = get_search("Batman!");
- print Dumper \$json;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement