how to create and setup facebook application on Amazon EC2 instance

After setting up the facebook application development platform on Amazon EC2 follwing this link, users can simply follow the README file located at "/var/apache2/2.2/htdocs/footprints/README" to test out the sample "footprints" application.

Here are the detailed steps, one can follow to sucessfully deploy the sample facebook application available on Amazon EC2 instance.

[step-1]
bash # cd /var/apache2/2.2/htdocs/footprints
bash # ls
config.php  index.php   lib.php     README

[step-2]
edit the config.php and set
$db_ip = 'localhost';
$db_pass = '';

if you have changed your db password, set it accordingly.

[step-3]
create database needed for the sample application. Database script for creating table structure is available in the config.php file.

­bash­3.2# /usr/mysql/bin/mysql ­u root
Welcome to the MySQL monitor.  Commands end with ; or \\g.
Your MySQL connection id is 1
Server version: 5.0.45 Source distribution
Type 'help;' or '\\h' for help. Type '\\c' to clear the buffer.

mysql> create database footprints;
Query OK, 1 row affected (0.00 sec)
 
mysql> use footprints
Database changed

mysql> 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`)
    ­> );

Query OK, 0 rows affected (0.01 sec)

mysql> select \* from footprints;
Empty set (0.00 sec)

mysql>

[step-4]
open http://apps.facebook.com/ and login with your facebook username and password.
goto the Developer section and click on the "Setup new application".

Provide appropriate application name and agree to the terms and conditions. finally click on the submit button to create the new application.

setup new application


[step-5]
Click on the "Edit Settings" and provide following details.

Call back URL:
http://ec2-XX-XX-XX-XXX.compute1.amazonaws.com/footprints

Canvas page URL:
http://apps.facebook.com/osolami

replace osolami with any avaiable string, to identify your application.

Check mark on  "Can your application be added on facebook?"

In the default FBML text box provide follwing

<fb:ifisownprofile>
<br />Hi
<fb:name uid="profileowner" firstnameonly="true" useyou="false"/>! This is the default FBML as specified
in Footprints' account configuration page. This will get replaced the first
time you get stepped on.
</fb:ifisownprofile>


after the change, click on "Save" button to update the settings.

facebook application settings page


facebook application settings


facebook application info page

[step-6]

Copy API Key and Secret Key from the above page and change that in to
/var/apache2/2.2/htdocs/footprints/config.php

after the change config.php should look like as given below

bash # cat config.php

<?php

// Get these from http://developers.facebook.com

$api_key = 'd4ec887d2c2d820300eb95785fa5bd68';

$secret = 'a8db36baf5c93f3673fce7ea799d6b40';

/\* While you're there, you'll also want to set up your callback url to the url

\* of the directory that contains Footprints' index.php, and you can set the

\* framed page URL to whatever you want. You should also swap the references

\* in the code from http://apps.facebook.com/footprints/ to your framed page URL. \*/


// The IP address of your database

$db_ip = 'localhost';
$db_user = 'root';

$db_pass = '';


// the name of the database that you create for footprints.
$db_name = 'footprints';

/\* 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`)

)


[step-7]

Replace the URL http://apps.facebook.com/footprints/ to http://apps.facebook.com/osolami/
in /var/apache2/2.2/htdocs/footprints/lib.php

Note: Here "http://apps.facebook.com/osolami/" is your canvas page URL. make the necessary changes accordingly.

[step-8]

Every thing is set. Now we are ready to hit the application URL
http://apps.facebook.com/osolami/
provide facebook username and password to login in

facebook application login page

[step-9]
Once you are logged in. You will see your sample facebook application running on EC2 instance.

It should look like as given below.

facebook application preview


facebook application preview


"leave your foot prints on some of your friends by steping upon them, and see the database table with updated stepping history".

bash # /usr/mysql/bin/mysql -u root

Welcome to the MySQL monitor. Commands end with ; or \\g.

Your MySQL connection id is 5

Server version: 5.0.45 Source distribution

Type 'help;' or '\\h' for help. Type '\\c' to clear the buffer.


mysql> use footprints;

Database changed

mysql> select \* from footprints;

+-----------+------------+------------+

| from | to | time |

+-----------+------------+------------+

| 51760XXXX | 101467XXXX | 1223533149 |

+-----------+------------+------------+

1 row in set (0.00 sec)

mysql>


You are all done and set with the sample facebook application on amazon ec2 instance.

Comments:

Hello divyen nice to read this topic "how to create and setup facebook application on Amazon EC2 instance".
But please help me out to make database in EC2 instance for my own website..

Thanks In Advance.

Gagan

Posted by Gagan Sharma on March 18, 2010 at 03:53 PM PDT #

Hi Gagan,

You can start with the preconfigured MySQL AMI.

Here is the AMI details.
http://developer.amazonwebservices.com/connect/entry.jspa?externalID=2223

Let me know if you need any help.

Regards,
Divyen Patel

Posted by Divyen Patel on March 19, 2010 at 04:04 AM PDT #

Post a Comment:
  • HTML Syntax: NOT allowed
About

Divyen Patel

Search

Categories
Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today