OVH hosting and Facebook apps

Posted: Thursday June 07 2012 @ 1:18pm  in Category: Software

You have a cheap hosting at OVH, and you'd like to create apps or page tabs on Facebook? The main issue is that Facebook requires that your app is available on a HTTPS website, with a valid SSL certificate... Fortunately, there's a solution even if your app is on OVH !

First, follow the basic setup part in this excellent Hyperarts tutorial.

Then, the trick is on the "Page Tabs" settings. The "Page Tab URL" could be, as shown in the tutorial "http://www.mydomain.com/facebook/mytestapp/", but if you simply add 'https' for the "Secure Page Tab URL", it won't work because the SSL certificate is not valid.

So, you have the use this URL instead: https://sslXX.ovh.net/~myovhuserid/facebook/mytestapp/ , where:

  • 'sslXX' is your OVH SSL server name and number, you can find it in your 'OVH Manager'
  • 'myovhuserid' is the same as your FTP upload account name.

Then, the follow the rest of the tutorial. Of course, to add the tab to your page use the right URL:

https://www.facebook.com/dialog/pagetab?app_id=YOUR_APP_ID&
next=https://sslXX.ovh.net/~myovhuserid/facebook/mytestapp/

(In fact there was a bug today on Facebook so I had to use this link instead:)

https://www.facebook.com/add.php?api_key=YOUR_APP_ID&pages=1

You're now ready to enjoy making 'reveal tabs' on your FB page with simple PHP code like this:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<link rel="stylesheet" type="text/css" href="style.css" />
<style type="text/css">
 body {
 width:520px;
 margin:0; padding:0; border:0;
}
</style>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<body>
<div id="container">
<?
$signed_request = $_REQUEST["signed_request"];
list($encoded_sig, $payload) = explode('.', $signed_request, 2);
$data = base64_decode(strtr($payload, '-_', '+/'));
# Yes I could have used json_decode instead of a preg_match !
if (preg_match("/liked.?:true/", $data)) {
    print "You like my page, good!";
} else {
    print "Please click on the like button above, to unlock special content!";
}
?>
</div>
</body>
</html>

Have Fun!

Bookmark and Share

RSS 2.0 Feed