Flickr::API::Response - A response from the flickr API.


Flickr-API documentation Contained in the Flickr-API distribution.

Index


Code Index:

NAME

Top

Flickr::API::Response - A response from the flickr API.

SYNOPSIS

Top

  use Flickr::API;
  use Flickr::API::Response;

  my $api = new Flickr::API({'key' => 'your_api_key'});

  my $response = $api->execute_method('flickr.test.echo', {
                'foo' => 'bar',
                'baz' => 'quux',
        });

  print "Success: $response->{success}\n";

DESCRIPTION

Top

This object encapsulates a response from the Flickr API. It's a subclass of HTTP::Response with the following additional keys:

  {
	'success' => 1,
	'tree' => XML::Parser::Lite::Tree,
	'error_code' => 0,
	'error_message' => '',
  }

The _request key contains the request object that this response was generated from. This request will be a Flickr::API::Request object, which is a subclass of HTTP:Request.

The sucess key contains 1 or 0, indicating whether the request suceeded. If it failed, error_code and error_message explain what went wrong. If it suceeded, tree contains an XML::Parser::Lite::Tree object of the response XML.

AUTHOR

Top

Copyright (C) 2004, Cal Henderson, <cal@iamcal.com>

SEE ALSO

Top

Flickr::API, XML::Parser::Lite


Flickr-API documentation Contained in the Flickr-API distribution.

package Flickr::API::Response;

use strict;
use warnings;
use HTTP::Response;

our @ISA = qw(HTTP::Response);

our $VERSION = '0.02';

sub new {
	my $class = shift;
	my $self = new HTTP::Response;
	my $options = shift;
	bless $self, $class;
	return $self;
}

sub init_flickr {
	my ($self, $options) = @_;
	$self->{tree} = undef;
	$self->{success} = 0;
	$self->{error_code} = 0;
	$self->{error_message} = '';	
}

sub set_fail {
	my ($self, $code, $message) = @_;
	$self->{success} = 0;
	$self->{error_code} = $code;
	$self->{error_message} = $message;
}

sub set_ok {
	my ($self, $tree) = @_;
	$self->{success} = 1;
	$self->{tree} = $tree;
}

1;

__END__