<card>
# FacebookResponse for the Facebook SDK for PHP

Represents a response from the Graph API.
</card>

<card>
## Facebook\FacebookResponse {#overview}

After sending a request to the Graph API, the response will be returned in the form of a `Facebook\FacebookResponse` entity.

Usage:

~~~~
$fb = new Facebook\Facebook(/* . . . */);

// Send the request to Graph
try {
  $response = $fb->get('/me');
} catch(Facebook\Exceptions\FacebookResponseException $e) {
  // When Graph returns an error
  echo 'Graph returned an error: ' . $e->getMessage();
  exit;
} catch(Facebook\Exceptions\FacebookSDKException $e) {
  // When validation fails or other local issues
  echo 'Facebook SDK returned an error: ' . $e->getMessage();
  exit;
}

var_dump($response);
// class Facebook\FacebookResponse . . .
~~~~
</card>

<card>
## Instance Methods {#instance-methods}

### getRequest() {#get-request}
~~~~
public Facebook\FacebookRequest getRequest()
~~~~
Returns the original [`Facebook\FacebookRequest`](/docs/php/FacebookRequest) entity that was used to solicit this response.
</card>

<card>
### getAccessToken() {#get-access-token}
~~~~
public string getAccessToken()
~~~~
Returns the access token that was used for the original request in the form of a string.
</card>

<card>
### getApp() {#get-app}
~~~~
public Facebook\FacebookApp getApp()
~~~~
Returns the [`Facebook\FacebookApp`](/docs/php/FacebookApp) entity that was used with the original request.
</card>

<card>
### getHttpStatusCode() {#get-http-status-code}
~~~~
public int getHttpStatusCode()
~~~~
Returns the HTTP response code for this response.
</card>

<card>
### getHeaders() {#get-headers}
~~~~
public array getHeaders()
~~~~
Returns the response headers that were returned.
</card>

<card>
### getBody() {#get-body}
~~~~
public string getBody()
~~~~
Returns the raw, unparsed body of the response as a string.
</card>

<card>
### getDecodedBody() {#get-decoded-body}
~~~~
public array getDecodedBody()
~~~~
Returns the parsed body of the response as an array.
</card>

<card>
### getAppSecretProof() {#get-app-secret-proof}
~~~~
public string getAppSecretProof()
~~~~
Returns the original [app secret proof](https://developers.facebook.com/docs/graph-api/securing-requests/#appsecret_proof) that was used with the original request.
</card>

<card>
### getETag() {#get-etag}
~~~~
public string getETag()
~~~~
Returns the `ETag` response header if it exists. If the header does not exist in the response headers, `null` will be returned instead.
</card>

<card>
### getGraphVersion() {#get-graph-version}
~~~~
public string getGraphVersion()
~~~~
Returns the Graph version that was used by returning the value from the `Facebook-API-Version` response header if it exists. If the header does not exist in the response headers, `null` will be returned instead.
</card>

<card>
### isError() {#is-error}
~~~~
public boolean isError()
~~~~
If the Graph API returned an error response `isError()` will return `true`. If a successful response was returned, `isError()` will return `false`.
</card>

<card>
### throwException() {#throw-exception}
~~~~
public throwException()
~~~~
Throws the [`Facebook\Exceptions\FacebookResponseException`](/docs/php/FacebookResponseException) that was generated by an error response from Graph.
</card>

<card>
### getThrownException() {#get-thrown-exception}
~~~~
public Facebook\Exceptions\FacebookResponseException getThrownException()
~~~~
Returns the [`Facebook\Exceptions\FacebookResponseException`](/docs/php/FacebookResponseException) that was generated by an error response from Graph. This is mainly useful for dealing with [responses to batch requests](/docs/php/FacebookBatchResponse).
</card>

<card>
### getGraphObject() {#get-graph-object}
~~~~
public Facebook\GraphNodes\GraphObject getGraphObject()
~~~~
Returns the response data in the form of a [`Facebook\GraphNodes\GraphObject`](/docs/php/GraphObject) collection.
</card>

<card>
### getGraphAlbum() {#get-graph-album}
~~~~
public Facebook\GraphNodes\GraphAlbum getGraphAlbum()
~~~~
Returns the response data in the form of a [`Facebook\GraphNodes\GraphAlbum`](/docs/php/GraphObject#album-instance-methods) collection.
</card>

<card>
### getGraphPage() {#get-graph-page}
~~~~
public Facebook\GraphNodes\GraphPage getGraphPage()
~~~~
Returns the response data in the form of a [`Facebook\GraphNodes\GraphPage`](/docs/php/GraphObject#page-instance-methods) collection.
</card>

<card>
### getGraphSessionInfo() {#get-graph-session-info}
~~~~
public Facebook\GraphNodes\GraphSessionInfo getGraphSessionInfo()
~~~~
Returns the response data in the form of a [`Facebook\GraphNodes\GraphSessionInfo`](/docs/php/GraphObject#sessioninfo-instance-methods) collection.
</card>

<card>
### getGraphUser() {#get-graph-user}
~~~~
public Facebook\GraphNodes\GraphUser getGraphUser()
~~~~
Returns the response data in the form of a [`Facebook\GraphNodes\GraphUser`](/docs/php/GraphObject#user-instance-methods) collection.
</card>

<card>
### getGraphList() {#get-graph-list}
~~~~
public Facebook\GraphNodes\GraphList getGraphList()
~~~~
Returns the response data in the form of a [`Facebook\GraphNodes\GraphList`](/docs/php/GraphList) collection.
</card>
