PHP Constructor

From Facebook Developer Wiki (FbDevWiki.com)
Jump to: navigation, search

You need to create an instance of the "Facebook" object in PHP in order to call the methods of that object. The constructor takes a single associative array as an argument. If you create the new object by $facebook = new Facebook(array( ... )); then you can call all of the methods by $facebook->some_method( ... ); afterwards.


Example:

 require 'facebook.php';

 $facebook = new Facebook(array(
   'appId'  => 'YOUR APP ID',
   'secret' => 'YOUR API SECRET',
   'cookie' => true, // enable optional cookie support
   'domain' => '.example.com'
 ));


Parameters

Name Type Description
config array
Property Type Description Required / Default Value Possible Values / Examples
appId string Your application ID (available in developer application) Required
secret string Your application secret (available in developer application) Required
cookie boolean boolean true to enable cookie support false
domain string domain for the cookie '' (which ever domain is currently being used '.example.com' - cookie will work on http://example.com and http://www.example.com
fileUpload boolean boolean indicating if file uploads are enabled (comment in code says: "Indicates if the CURL based @ syntax for file uploads is enabled.") You can also temporarily set this to true with the PHP getters/setters. false

All of the constructor arguments can be changed after initializing the Facebook object by use of the PHP getters/setters.

Personal tools
Namespaces
Variants
Actions
Navigation
Graph API
FQL
Toolbox