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.
Warning: Declaration of Social_Walker_Comment::start_lvl(&$output, $depth, $args) should be compatible with Walker_Comment::start_lvl(&$output, $depth = 0, $args = Array) in /Users/wade/Sites/hm2k.org/wp-content/plugins/social/lib/social/walker/comment.php on line 18
Warning: Declaration of Social_Walker_Comment::end_lvl(&$output, $depth, $args) should be compatible with Walker_Comment::end_lvl(&$output, $depth = 0, $args = Array) in /Users/wade/Sites/hm2k.org/wp-content/plugins/social/lib/social/walker/comment.php on line 42
i am not able to read your instructions on commenting out lib.php….
Thanx a lot 🙂
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)
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.
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.
Thanks for the link to Ister!
How to deal with the try/catch syntax
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…
where to extract the folder “simplexml44-0_4_4”
should this be inside footprints folder?
how should i add reference to this library?
thanks
not in footprints buddy … you have to put the “simplexml44-0_4_4” folder inside “php4client” folder …
greets 😉