Facebook share button (PHP)

  • 51 favourites

Stats

8,643 visits, 13,180 views

Translations

This tutorial hasn't been translated.

Tools

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!

  • 0 Comments

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