Know another language? Translate this tutorial!

Facebook share button (PHP)

Favourite 53 favourites
Tutorial written by stctrOriginally published on 15th, March 2014 - 1 revision

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=""/>
    <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=" />

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:
Open full size image

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!

Unlock your full gamedev potential

Upgrade to the Personal Edition of Construct 2, it has way more features and won't holding back from making money and using your full creativity like the free edition does. It's a one off payment and all Construct 2 editor updates are free for life!

View deals

Plus, it's got a lot of additional features that will help you save time and make more impressive games!

Congratulations on finishing this tutorial!

Did you learn a lot from it? Share it now with your friends!

Share and Copy this Tutorial

You are free to copy, distribute, transmit and adapt this work with correct attribution. Click for more info.


hd4real 398 rep

Hi, I tested this but highscore shows the 5000 from the event code and not the 38 highscore from my game. What did I do wrong?

Saturday, March 15, 2014 at 9:27:41 PM
Lordshiva1948 44.3k rep

highscore is not working properly could be my mistake not sure but, thanks for sharing

Sunday, March 16, 2014 at 6:21:17 AM
ArcadEd 22.2k rep

This may work with cocoonJS as we'll. thanks, I will try it.

Sunday, March 16, 2014 at 5:31:22 PM
bremen 2,645 rep

@ArcadED did you manage to get this to work on CocoonJS? I'm very interested in this I'm working on mine now.

Monday, March 17, 2014 at 5:49:39 AM
stctr 6,141 rep

Go to "" & "5000" & ":" & random(1,10) in a new window ("NewWindow")

Instead of 5000 you have to write something like,
Go to "" & Webstorage.LocalValue("highscore") & ":" & random(1,10) in a new window ("NewWindow")

Webstorage.LocalValue("highscore") Here you give the right number to post.

This system works with CocoonJs.


Monday, March 17, 2014 at 9:00:07 PM
amkp 2,165 rep

Nice tip, thanks! And for tweeter ? ^^

Tuesday, March 18, 2014 at 12:34:43 PM
diegocaetanop 387 rep

error syntax please view screenshot http : / / prntscr .com/32p8x2

Friday, March 21, 2014 at 5:22:23 AM
mrnannings 3,508 rep

Can you make a plugin like this for c2

Friday, March 21, 2014 at 7:48:08 AM
stctr 6,141 rep


I will submit a tutorial for tweeter today.


Delete : in a new window ("NewWindow")
That line will be added automatically by Construct2. :)


I can't code plugins sorry.

Friday, March 21, 2014 at 9:31:04 AM
amkp 2,165 rep

"I will submit a tutorial for tweeter today."

Cool !

Sunday, March 23, 2014 at 9:47:12 AM
stctr 6,141 rep
"I will submit a tutorial for tweeter today."

Cool !
quoted from amkp

Just made a tutorial for twitter :

Sunday, March 23, 2014 at 10:56:29 PM
bremen 2,645 rep

Great Job! Thanks for the Tutorial

Sunday, March 23, 2014 at 11:19:43 PM
Pariunos 853 rep

Can the share.php file be hosted on google drive or does it have to be an actual server?

Friday, March 28, 2014 at 9:05:39 AM
gfigueroa 2,209 rep

Thanks for the tutorial, it works great with Windows 8 PC, but I have not been able to make it work with Windows Phone, has anyone tried it with Windows Phone?

Saturday, March 29, 2014 at 5:35:48 PM
irina 6,924 rep


Thanks for this one!

Any chance of showing show how to set a simple "like" button?

Monday, March 31, 2014 at 9:27:24 AM

Leave a comment

Everyone is welcome to leave their thoughts! Register a new account or login.