Developing a Facebook Application on PHP4
I want to create a facebook application, however currently all my production servers run PHP4.
Ultimately the project will be appear on your Facebook profile as a profile box.
I’m writing this while I begin creating my facebook application to assist people in a similar situation to myself.
So to begin with we will start at the Official Facebook Step-by-step Guide to Creating an Application.
This is all fine, until you get to about step 10 of “Integrating Hello World”, you quickly realise that this guide is for PHP5 users…
If you followed the guide correctly, you should have added yourself an application to Facebook, and got your API key, etc. You should also have a copy of the PHP (4 and 5) Client Library.
The next step is to follow the directions in the README file that comes with the Client Library and setup the “example” facebook application called Footprints.
Below is a step by step guide on how to achieve this:
- Create a new directory, and copy the following files from the library to it…
- ./footprints/config.php
- ./footprints/index.php
- ./footprints/lib.php
- ./php4client/facebook.php
- ./php4client/facebookapi_php4_restlib.php
- Edit “index.php”, change “include_once ‘../client/facebook.php’;” to “include_once ‘facebook.php’;”
- Edit “config.php”, ensure you set the $api_key; $secret; $db_ip; $db_user; $db_pass; $db_pass; $db_name correctly. Note, obviously at this point you need to create a user/database and from reading the file, at the bottom you need to create the table called “footprints”, I did this by loading up phpmyadmin and running the SQL.
- To get this to work correctly for php4, you also need simplexml44, it should extract into a directory named “simplexml44-0_4_4″, you will need this.
- If like me you have discovered that lib.php errors because of the try-catch, don’t worry. just comment them out.
If you have done everything correctly, you should be at a point when you are ready to start editing the “index.php” and the functions in “lib.php”.
From this point onwards you need to understand PHP and read the developers documentation on the facebook website to continue.
It was interesting up until this point. I pretty much figured the best approach was to have an already existing project or site then you would simply make an application for that.
Tip: I suggest if you plan on making an application, make the project first.
mathieu said,
October 11, 2007 @ 7:47 pm
i am not able to read your instructions on commenting out lib.php….
Grady said,
October 19, 2007 @ 4:39 am
Thanx a lot
Abdul Barek said,
October 25, 2007 @ 7:10 am
I wanna know how a php application can be integrated in the facebook (please give me screen shoot sequences of how the application is integrated)
rw1 said,
November 8, 2007 @ 4:02 am
hello, i am trying to follow readme instructions as to how to set up my first app.
it says to add a table to the database.
i am using phpMyAdmin and when i go to add a table it asks me how many fields.
how many fields does that table need to have?
thank you.
ps i also cannot access commenting out instructions.
Stuart said,
November 27, 2007 @ 3:02 pm
This is really helpfull but can you please show me how to fix the lib.php file.
After commenting out the try-catch stuff, it says hello and gives me the option to step on people but I still get a few errors and it doesn’t update my database.
Please show me how you did it,
Cheers
oh, and rw1 said, its at the bottom of the config.php file:
/* create this table on the database:
CREATE TABLE `footprints` (
`from` int(11) NOT NULL default ‘0′,
`to` int(11) NOT NULL default ‘0′,
`time` int(11) NOT NULL default ‘0′,
KEY `from` (`from`),
KEY `to` (`to`)
)
*/
so 3 fields: from,to and time. Hope that helps.
Morgan said,
December 12, 2007 @ 5:34 pm
Thanks for the link to Ister!
Nkosinathi said,
January 25, 2008 @ 11:34 am
How to deal with the try/catch syntax
Pekka said,
June 9, 2008 @ 10:46 am
Also notice that footprints application uses . json_encode() and . json_decode() functions - which are implemented in PHP 5.2… So if you have something lower (I have 5.1.6) footprints doesn’t work after all…
Siddiq said,
August 19, 2008 @ 7:10 pm
where to extract the folder “simplexml44-0_4_4″
should this be inside footprints folder?
how should i add reference to this library?
thanks
gerardo said,
November 13, 2008 @ 10:30 pm
not in footprints buddy … you have to put the “simplexml44-0_4_4″ folder inside “php4client” folder …
greets