{"id":15408352,"url":"https://github.com/yusukebe/webservice-simple","last_synced_at":"2025-04-18T16:18:51.860Z","repository":{"id":10143610,"uuid":"12219304","full_name":"yusukebe/WebService-Simple","owner":"yusukebe","description":"Simple Interface To Web Services APIs","archived":false,"fork":false,"pushed_at":"2020-02-02T21:55:33.000Z","size":351,"stargazers_count":5,"open_issues_count":2,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-29T06:33:20.938Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://search.cpan.org/dist/WebService-Simple/","language":"Perl","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yusukebe.png","metadata":{"files":{"readme":"README.md","changelog":"Changes","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-08-19T14:50:42.000Z","updated_at":"2015-02-11T12:02:24.000Z","dependencies_parsed_at":"2022-08-30T11:01:27.717Z","dependency_job_id":null,"html_url":"https://github.com/yusukebe/WebService-Simple","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yusukebe%2FWebService-Simple","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yusukebe%2FWebService-Simple/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yusukebe%2FWebService-Simple/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yusukebe%2FWebService-Simple/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yusukebe","download_url":"https://codeload.github.com/yusukebe/WebService-Simple/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249517783,"owners_count":21284836,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-01T16:33:37.344Z","updated_at":"2025-04-18T16:18:51.841Z","avatar_url":"https://github.com/yusukebe.png","language":"Perl","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/yusukebe/WebService-Simple.svg?branch=master)](https://travis-ci.org/yusukebe/WebService-Simple)\n# NAME\n\nWebService::Simple - Simple Interface To Web Services APIs\n\n# SYNOPSIS\n\n    use WebService::Simple;\n\n    # Simple use case\n    my $flickr = WebService::Simple-\u003enew(\n      base_url =\u003e \"http://api.flickr.com/services/rest/\",\n      param    =\u003e { api_key =\u003e \"your_api_key\", }\n    );\n\n    # send GET request to \n    # http://api.flickr.com/service/rest/?api_key=your_api_key\u0026method=flickr.test.echo\u0026name=value\n    $flickr-\u003eget( { method =\u003e \"flickr.test.echo\", name =\u003e \"value\" } );\n\n    # send GET request to \n    # http://api.flickr.com/service/rest/extra/path?api_key=your_api_key\u0026method=flickr.test.echo\u0026name=value\n    $flickr-\u003eget( \"extra/path\",\n      { method =\u003e \"flickr.test.echo\", name =\u003e \"value\" });\n\n# DESCRIPTION\n\nWebService::Simple is a simple class to interact with web services.\n\nIt's basically an LWP::UserAgent that remembers recurring API URLs and\nparameters, plus sugar to parse the results.\n\n# METHODS\n\n- new(_%args_)\n\n        my $flickr = WebService::Simple-\u003enew(\n            base_url =\u003e \"http://api.flickr.com/services/rest/\",\n            param    =\u003e { api_key =\u003e \"your_api_key\", },\n            # compression  =\u003e 0\n            # content_type =\u003e 'application/json'\n            # croak        =\u003e 0\n            # debug        =\u003e 1\n        );\n\n    Create and return a new WebService::Simple object.\n    \"new\" Method requires a base\\_url of Web Service API.\n\n    By default, the module calls Carp::croak (dies) on unsuccessful HTTP requests. If\n    you want to change this behaviour, set croak to FALSE and get() or post() will return\n    the HTTP::Response object on success and failure, just like the base LWP::UserAgent.\n\n    By default the module will attempt to use HTTP compression if the Compress::Zlib\n    module is available. Pass compress =\u003e 0 to -\u003enew() to disable this feature.\n\n    If debug is set, the request URL will be dumped via warn() on get or post method calls .\n\n- get(_\\[$extra\\_path,\\] $args_)\n\n        my $response =\n          $flickr-\u003eget( { method =\u003e \"flickr.test.echo\", name =\u003e \"value\" } );\n\n    Send a GET request, and you can get the WebService::Simple::Response object.\n    If you want to add a path to base URL, use an option parameter.\n\n        my $lingr = WebService::Simple-\u003enew(\n            base_url =\u003e \"http://www.lingr.com/\",\n            param    =\u003e { api_key =\u003e \"your_api_key\", format =\u003e \"xml\" }\n        );\n        my $response = $lingr-\u003eget( 'api/session/create', {} );\n\n- post(_$args\\_ref, @headers_)\n- post(_$extra\\_path, $args\\_ref, @headers_)\n- post(_$extra\\_path, @headers_)\n\n    Send a POST request.\n\n        my $ws = WebService::Simple-\u003enew(\n            base_url =\u003e 'http://example.com/',\n            param   =\u003e  { aaa =\u003e 'zzz' },\n        );\n        my $response = $ws-\u003epost('api/echo', { hello =\u003e 'world'});\n\n    By default, POST requests will have Content-Type application/x-www-form-urlencoded.\n    That means, the content of a post request, the message body, is a string of your\n    urlencoded parameters. You can change this by setting a different default value\n    upon construction by passing content\\_type =\u003e 'application/json' to -\u003enew(). Or on\n    a per-request basis by setting the Content-Type header. JSON request encoding is\n    currently the only supported content type for this feature.\n\n        my $ws = WebService::Simple-\u003enew(\n            base_url =\u003e 'http://example.com/',\n            param   =\u003e  { aaa =\u003e 'zzz' },\n        #   content_type =\u003e 'application/json', # either here\n        );\n        my $response = $ws-\u003epost('api/echo', { hello =\u003e 'world' }, 'Content-Type' =\u003e 'application/json'); # or here\n\n- request\\_url(_$extra\\_path, $args_)\n\n    Return request URL.\n\n- base\\_url\n- basic\\_params\n- cache\n\n    Each request is prepended by an optional cache look-up. If you supply a Cache\n    object to new(), the module will look into the cache first.\n\n        my $cache   = Cache::File-\u003enew(\n            cache_root      =\u003e '/tmp/mycache',\n            default_expires =\u003e '30 min',\n        );\n        \n        my $flickr = WebService::Simple-\u003enew(\n            base_url =\u003e \"http://api.flickr.com/services/rest/\",\n            cache    =\u003e $cache,\n            param    =\u003e { api_key =\u003e \"your_api_key, }\n        );\n\n- response\\_parser\n\n    See PARSERS below.\n\n# SUBCLASSING\n\nFor better encapsulation, you can create subclass of WebService::Simple to\ncustomize the behavior\n\n    package WebService::Simple::Flickr;\n    use base qw(WebService::Simple);\n    __PACKAGE__-\u003econfig(\n      base_url =\u003e \"http://api.flickr.com/services/rest/\",\n      upload_url =\u003e \"http://api.flickr.com/services/upload/\",\n    );\n\n    sub test_echo\n    {\n      my $self = shift;\n      $self-\u003eget( { method =\u003e \"flickr.test.echo\", name =\u003e \"value\" } );\n    }\n\n    sub upload\n    {\n      my $self = shift;\n      local $self-\u003e{base_url} = $self-\u003econfig-\u003e{upload_url};\n      $self-\u003epost( \n        Content_Type =\u003e \"form-data\",\n        Content =\u003e { title =\u003e \"title\", description =\u003e \"...\", photo =\u003e ... },\n      );\n    }\n\n# PARSERS\n\nWeb services return their results in various different formats. Or perhaps\nyou require more sophisticated results parsing than what WebService::Simple\nprovides.\n\nWebService::Simple by default uses XML::Simple, but you can easily override\nthat by providing a parser object to the constructor:\n\n    my $service = WebService::Simple-\u003enew(\n      response_parser =\u003e AVeryComplexParser-\u003enew,\n      ...\n    );\n    my $response = $service-\u003eget( ... );\n    my $thing = $response-\u003eparse_response;\n\nFor example. If you want to set XML::Simple options, use WebService::Simple::Parser::XML::Simple\nincluding this module:\n\n    use WebService::Simple;\n    use WebService::Simple::Parser::XML::Simple;\n    use XML::Simple;\n    \n    my $xs = XML::Simple-\u003enew( KeyAttr =\u003e [], ForceArray =\u003e ['entry'] );\n    my $service = WebService::Simple-\u003enew(\n        base_url =\u003e \"http://gdata.youtube.com/feeds/api/videos\",\n        param    =\u003e { v =\u003e 2 },\n        response_parser =\u003e\n          WebService::Simple::Parser::XML::Simple-\u003enew( xs =\u003e $xs ),\n    );\n\nThis allows great flexibility in handling different Web Services\n\n# REPOSITORY\n\nhttps://github.com/yusukebe/WebService-Simple\n\n# AUTHOR\n\nYusuke Wada  `\u003cyusuke@kamawada.com\u003e`\n\nDaisuke Maki `\u003cdaisuke@endeworks.jp\u003e`\n\nMatsuno Tokuhiro\n\nNaoki Tomita (tomi-ru)\n\n# COPYRIGHT AND LICENSE\n\nThis module is free software; you can redistribute it\nand/or modify it under the same terms as Perl itself.\nSee [perlartistic](https://metacpan.org/pod/perlartistic).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyusukebe%2Fwebservice-simple","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyusukebe%2Fwebservice-simple","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyusukebe%2Fwebservice-simple/lists"}