Creating facebook application on localhost

April 22, 2015

As We know for Facebook Canvas we need server having ssl certificate installed.
We are going to install ssl on Xampp.

  1. Open “C:\xampp\apache\conf\extra\httpd-vhosts.conf” file , append the following code and save it.Restart Xampp and you are done with ssl.Now you can access “https://localhost/myfbapp/”.If you want to avoid the security warning for this url,you can add this certificate to your browser(not necessary).
    Note:-Replace “myfbapp” with the root directory of your project.And also change the path to Xampp if yours is different(i.e D:\).

    NameVirtualHost *:80
    NameVirtualHost *:443
    
    <VirtualHost *:80>
        DocumentRoot "C:\xampp\htdocs"
        ServerName localhost
    </VirtualHost>
    <VirtualHost *:443>
        DocumentRoot "C:\xampp\htdocs\myfbapp"
        ServerName project_one.localhost
        SSLEngine on
        SSLCertificateFile "conf/ssl.crt/server.crt"
        SSLCertificateKeyFile "conf/ssl.key/server.key"
        <Directory "C:\xampp\htdocs\myfbapp">
            AllowOverride All
            Order allow,deny
            Allow from all
        </Directory>
    </VirtualHost>
    <VirtualHost *:80>
        DocumentRoot "C:\xampp\htdocs\myfbapp"
        ServerName project_two.localhost
        <Directory "C:\xampp\htdocs\myfbapp">
            AllowOverride All
            Order allow,deny
            Allow from all
        </Directory>
    </VirtualHost>
    

  2. Now Go to your facebook app created on developers.facebook.com and put “https://localhost/myfbapp/” wherever needed.Save it.
  3. Access your Canvas Page URL.You will see your app is working.

  4. This Canvas Page URL will only work for your machine as we have done it using “localhost”.

No Comments

Leave a Reply

Your email address will not be published. Required fields are marked *