Facebook share button (PHP)

1

Stats

11,684 visits, 17,151 views

Tools

Translations

This tutorial hasn't been translated.

License

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.

Published on 15 Mar, 2014. Last updated 19 Feb, 2019

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 :

    <?php
    $score = $_GET["score"];
    $scorex = explode(":", $score);
    $highscore = $scorex[0];
    ?>
    <html>
    <head>
    <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!"/>	
    </head>
    <body>
    <meta http-equiv="refresh" content="0;URL=http://www.yoursite.com" />
    </body>
    </html>

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 :

play.google.com/store/apps/details

I hope this tutorial will help you guys, Enjoy!

  • 1 Comments

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