Sunday, December 22, 2013

How to create a new facebook app and to be attached to facebook tab

1) you need to register as facebook developer
a) Login as kwonghong@yahoo.com
b) Refer to the

c) create a new app and choose the Facebook app and page tab app type.

Now you need to specify the URL for your app ? next step ..

2) You need to create a new app via heroku.
Login to a ubuntu server and create a directory as show below

Since this is a free acount, you can only create up to 5 applications

cd ~/heroku/cornery4
git init
git add
git status
git commit -m "add app"
heroku create
git push heroku master

if you want upload a new code, do the following

git add
git commit -m "add app"
git push heroku master

3) one of the requirement is able to send email from heroku. The latter doesn't allow SMTP server hence you need to install "add on". For this example, I have installed "SendGrid" add on and also need to add the following into your code.

$url = 'http://sendgrid.com/';
$user = 'app20508217@heroku.com';
$pass = '9wfghcrn';
$params = array(
      'api_user' => $user,
      'api_key' => $pass,
      'to' => 'info@cornery.com.my',
      'subject' => 'Franchise Enquiry',
      'html' => $email_message,
      'text' => 'Franchise',
      'from' => $iemail,
   );
$request = $url.'api/mail.send.json';
 // Generate curl request
 $session = curl_init($request);
 // Tell curl to use HTTP POST
 curl_setopt ($session, CURLOPT_POST, true);
 // Tell curl that this is the body of the POST
 curl_setopt ($session, CURLOPT_POSTFIELDS, $params);
 // Tell curl not to return headers, but do return the response
 curl_setopt($session, CURLOPT_HEADER, false);
 curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
 // obtain response
 $response = curl_exec($session);
 curl_close($session);
4) I have created two facebook tabs - franchise and special events.
Franchise is at ~heroku/cornery3
Special Event ~heroku/cornery4