++ed by:
MISHIN PAWAPAWA KEEDI

3 PAUSE users
2 non-PAUSE users.

Go Hagiwara
and 2 contributors

NAME

Facebook::OpenGraph::Response - Response object for Facebook::OpenGraph.

SYNOPSIS

  my $res = Facebook::OpenGraph::Response->new(+{
      code        => $http_status_code,
      message     => $http_status_message,
      headers     => $response_headers,
      content     => $response_content,
      req_headers => $req_headers,
      req_content => $req_content,
      json        => JSON->new->utf8,
  });

DESCRIPTION

This handles response object for Facebook::OpenGraph.

METHODS

Class Methods

Facebook::OpenGraph::Response->new(\%args)

Creates and returns a new Facebook::OpenGraph::Response object.

%args can contain...

  • code

    HTTP status code

  • message

    HTTP status message

  • headers

    Response headers

  • content

    Response body

  • req_headers

    Stringified request headers

  • req_content

    Request content

  • json

    JSON object

Instance Methods

$res->code

Returns HTTP status code

$res->message

Returns HTTP status message

$res->content

Returns response body

$res->req_headers

Returns request header. This is especially useful for debugging. You must install later version of Furl to enable this or otherwise empty string will be returned. Also you have to specify Furl::HTTP->new(capture_request => 1) option.

$res->req_content

Returns request body. This is especially useful for debugging. You must install later version of Furl to enable this or otherwise empty string will be returned. Also you have to specify Furl::HTTP->new(capture_request => 1) option.

$res->etag

Returns ETag value that is given as a part of response headers.

$res->header($field_name)

Returns specified header field value.

  my $res  = $fb->request('GET', 'go.hagiwara');
  my $etag = $res->header('etag'); # "a376a57cb3a4bd3a3c6a53fca06b0fd5badee50b"

$res->api_version

By checking facebook-api-version header value, it returns API version that current API call actually experienced. This may differ from the one you specified. See https://developers.facebook.com/docs/apps/changelog#v2_1

$res->is_api_version_eq_or_older_than($comparing_version)

Compare $comparing_version with the facebook-api-version header value and returns TRUE when facebook-api-version is older than the given version.

$res->is_api_version_eq_or_later_than($comparing_version)

Compare $comparing_version with the facebook-api-version header value and returns TRUE when facebook-api-version is newer than the given version.

$res->is_success

Returns if status is 2XX or 304. 304 is added to handle $fb->fetch_with_etag();

$res->error_string

Returns error string.

$res->as_json

Returns response content as JSON string. Most of the time the response content itself is JSON formatted so it basically returns response content without doing anything. When Graph API returns plain text just saying 'true' or 'false,' it turns the content into JSON format like '{"success" : "(true|false)"}' so you can handle it in the same way as other cases.

$res->as_hashref

Returns response content in hash reference.

$res->is_modified

Returns if target object is modified. This method is called in $fb->fetch_with_etag().