Facebook share button (PHP)

  • 52 favourites


11,333 visits, 16,737 views



This tutorial hasn't been translated.


This tutorial is licensed under CC BY 4.0. Please refer to the license text if you wish to reuse, share or remix the content contained within this tutorial.

Hi, sorry for my bad English and grammar.

How to make a Facebook share button for your Construct2 games;

What you need:

1. You need a website that runs PHP.

2. You have to upload share.php on your server.

3. You got a facebook share button on your game.

share.php code :

    $score = $_GET["score"];
    $scorex = explode(":", $score);
    $highscore = $scorex[0];
    <title>Weebe Jello Jumper HighScore</title>
    <meta property="og:title" content="Highscore on Jello Jumper is <?echo $highscore;?>!"/>
    <meta property="og:image" content="http://weebe.nl/jellojumper/jello.png"/>
    <meta property="og:site_name" content="Weebe Game Studio"/>
    <meta property="og:description" content="<?echo $highscore;?> is mine new highscore on Jello Jumper! How far do you think you can get? Try it for free!"/>	
    <meta http-equiv="refresh" content="0;URL=http://www.yoursite.com" />

Change the information like titles, image paths, descriptions etc. for your own game.

The .php code above will show this on facebook :

In your game add the Browser object and this event:

Change the number 5000 with your own score, it could be something like : Webstorage.LocalValue("highscore"). Or else it will post 5000 every time.

The random number system is for Facebook cache, if the URL is already used in Facebook it will get the title etc from the cache not your website. That's why we give Facebook a new URL with random numbers every time.

It works with CocoonJS, i used it in my game for a demo check out :


I hope this tutorial will help you guys, Enjoy!


  • Order by
Want to leave a comment? Login or Register an account!