PHP
From Facebook Developer Wiki
Contents |
Official PHP Client Library
The official Facebook PHP Client Library package contains three directories and a README file.
- The php directory contains these core components:
- facebookapi_php5_restlib.php contains the implementation of the methods that constitute the client library.
- facebook.php contains a class that can be used by the web client application.
- facebook_desktop.php contains a class that can be used by the desktop client application.
- The php4client directory contains similar components for PHP4.
- The footprints directory contains code for a sample application called "footprints".
- See the facebook-platform/footprints/README file (from the .tar.gz archive) for additional information.
- one way of displaying the currently installed PHP libraries is to create a file named info.php containing the following code (delete file after use):
- <?php phpinfo(); ?>
- when editing the facebook-platform/footprints/config.php file, note the following:
- the API and the Secret Keys are best retrieved from https://www.facebook.com/developers/apps.php
- $db_ip can be set to the DNS hostname of the database server, instead of the IP address
- when editing the facebook-platform/footprints/index.php file, note the following:
- for greater security, the config.php file should be placed in a directory that is not accessible by end-users - if your hosting provider places your files into your home directory, the following steps can be followed:
- create a directory called private_footprints in your home directory
- move config.php into this directory
- change the config.php include statement in index.php as follows:
- for greater security, the config.php file should be placed in a directory that is not accessible by end-users - if your hosting provider places your files into your home directory, the following steps can be followed:
- // this defines some of your basic setup include_once '/home/username/private_footprints/config.php';
- any references to the "framed page URL" in the README and config.php files are analogous to referring to the Canvas URL
- to replace all references to the default footprints application Canvas URL in the lib.php file, try running the following from a bash shell:
- works for http://apps.facebook.com/yourappname/
- to replace all references to the default footprints application Canvas URL in the lib.php file, try running the following from a bash shell:
- sed -i -e 's/\/footprints/\/yourappname/g' facebook-platform/footprints/lib.php grep apps !$
Facebook Sample Application
Facebook created a sample application called Smiley that demonstrates all the major features of the new profile. You can download the Smiley source code. Note that Smiley & Facebook PHP Client Libraries are designed to work on PHP5.
Unofficial PHP5 PEAR package Services_Facebook
The current PHP5 library from Facebook doesn't support all of the API endpoints, photo uploads, etc. Services_Facebook supports all of the endpoints, except Data (partial experimental support is in SVN), along with photo uploads and it ships with unit tests that cover 100% of the code. Download the code from PEAR or visit the Google Project.
Usage
You can review a more detailed version of this code on Talk:PHP.
Unofficial PHP4 Client Library
- Description and download link can be found at [1].
- It should be noted that there is an official PHP4 client lib now included with the PHP5 client. It's inside the "php4client" folder within the PHP5 client. (see above) However, this folder is currently only present in the pre-profile-redesign client,
Unofficial PHP5 FB Utils Class
Here's a class I've put together to handle a bunch of facebook functions (I am using it to support the Dvolver MovieMaker application). It is very much a work in progress (I'm sure there are better ways to do a bunch of the things I'm doing). Feel free to make improvements and please send those back to me and I'll test and repost. There's a logging function in the class which you can just comment out.
Note: Please give us a description of some of the things your class does EyeRmonkey 11:17, 12 June 2007 (PDT)
Sending an Invitation To your Application Example
- Sample code form for the invite where fbuser is the user's facebook user id (barce@dogster.com):
As said here: Notifications.sendRequest this code is not valid anymore.
Sample PHP5 Code for Handling the Invite Form Submission
See Also
- PHP Sessions
- Makebeta - Facebook PHP Tutorial
- PHP UTF-8 Cheatsheet - step-by-step instructions for ensuring your MySQL and PHP applications support international languages
- Update - link is broken
