<card>
# FacebookApp for the Facebook SDK for PHP

In order to make requests to the Graph API, you need to [create a Facebook app](/apps) and obtain the app ID and the app secret. The `Facebook\FacebookApp` entity represents the Facebook app that is making the requests to the Graph API.

%FB(devsite:markdown-wiki:info-card {
  content: "It is quite uncommon to work with the `FacebookApp` entity directly since the `Facebook\\Facebook` service handles injecting it into the required classes for you.",
  type: 'warning',
})
</card>

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

To instantiate a new `Facebook\FacebookApp` entity, pass the app ID and app secret to the constructor.

~~~~
$fbApp = new Facebook\FacebookApp('{app-id}', '{app-secret}');
~~~~

Alternatively you can obtain the `Facebook\FacebookApp` entity from the [`Facebook\Facebook`](/docs/php/Facebook) super service class.

~~~~
$fb = new Facebook\Facebook([/* . . . */]);
$fbApp = $fb->getApp();
~~~~

You'll rarely be using the `FacebookApp` entity directly unless you're doing some extreme customizations of the SDK for PHP. But this entity plays an important role in the internal workings of the SDK for PHP.

## Instance Methods {#instance-methods}

## getAccessToken() {#get-access-token}
~~~~
public Facebook\Authentication\AccessToken getAccessToken()
~~~~
Returns an app access token in the form of an [`AccessToken`](/docs/php/AccessToken) entity.

## getId() {#get-id}
~~~~
public string getId()
~~~~
Returns an the app id.

## getSecret() {#get-secret}
~~~~
public string getSecret()
~~~~
Returns an the app secret.

## Serialization {#serialization}

The `Facebook\FacebookApp` entity can be serialized and unserialized.

~~~~
$fbApp = new Facebook\FacebookApp('foo-app-id', 'foo-app-secret');

$serializedFacebookApp = serialize($fbApp);
// C:29:"Facebook\\FacebookApp":54:{a:2:{i:0;s:10:"foo-app-id";i:1;s:14:"foo-app-secret";}}

$unserializedFacebookApp = unserialize($serializedFacebookApp);
echo $unserializedFacebookApp->getAccessToken();
// foo-app-id|foo-app-secret
~~~~
</card>
