2
\$\begingroup\$

I have my game made with Phaser (and compiled with cocoon.io) and on the leadersboard state I want to let the user to post his score on Facebook.

Well, I created an App on Facebook and I´m not finding a good solution to create this simple post, something like "I scored 10 points on this riduculous game..." Pretty easy on Twitter and not so easy on Facebook, I can find information about posting links and that stuff but I´m not finding a proper way to create a simple post just with text.

How do you guys do this? I guess I´m missing something, it shouldn´t be so complicated.

(I already tested this link and it´s not working for me Simple way to post score from my game to Facebook and Twitter? API Error Code: 191 API Error Description: The specified URL is not owned by the application Error Message: redirect_uri is not owned by the application.)

\$\endgroup\$
  • \$\begingroup\$ Are you using Facebook's Graph API? developers.facebook.com/docs/graph-api \$\endgroup\$ – mythos Nov 27 '15 at 15:17
  • \$\begingroup\$ I was, but it really sucks, so at the end I just linked to a webpage with a window.open. \$\endgroup\$ – torpedete Nov 29 '15 at 16:33
  • \$\begingroup\$ If you're using Facebook, be aware of the following: stallman.org/facebook.html \$\endgroup\$ – Lolums Dec 8 '15 at 18:14
0
\$\begingroup\$

First you'll need to setup Facebook JavaScript SDK: https://developers.facebook.com/docs/javascript/quickstart/v2.5

I have tried with open graph.

FB.ui({
 method: 'share_open_graph',
 action_type: 'namespace:action_type',
 action_properties: JSON.stringify({
     object_type:
      {
          'og:type': 'namespace:object_type',
          'og:title': 'I scored 10 points on this ridiculous game...',
          'og:image': 'http://www.bizreport.com/2011/02/03/android-logo-200x200.jpg',
          'og:description': 'Description'
      }
 })
}, function(response)
{
        if (response.post_id != null)
        {
            // handle response
        }
});

action_type and object_type are from Facebook application which I am sure you're familiar with.
And you'll need to submit the application for review if you're using custom stories.

Since I plan on using standard share dialog with custom image, text and link, I didn't spend much time figuring out open graph and how to set it up.

FB.ui({ method: 'feed',
    link: 'http://mysite.com/link-to-my-game',
    picture: 'http://www.bizreport.com/2011/02/03/android-logo-200x200.jpg',
    name: 'I scored 10 points on this ridiculous game...',
    description: 'Description',
    actions: [
        { name: 'Name of my site', link: 'http://mysite.com/' }
    ],
    display: 'popup'
  }, function (response)
  {
    if (response && response.post_id)
    {
        // handle response
    }
  });  

Here you can see other parameters you may need: https://developers.facebook.com/docs/sharing/reference/feed-dialog/v2.5

With this approach, sharing works as soon as you make your application public.
I need something simpler and I didn't want to submit the application for review, so I went with second option, but the first option is more powerful in terms of customizing.

About that redirect_uri error, I think it is because that redirect_uri domain is not listed in App Domains on your Facebook application Settings page. (correct me if I am wrong)

I am no expert at this, I just spent some time searching what I need, collected the code and played with it.

\$\endgroup\$
  • \$\begingroup\$ Still not working... I´m getting this error: Warning Action type namespace:action_type is invalid \$\endgroup\$ – torpedete Dec 10 '15 at 10:57
  • \$\begingroup\$ But the second approach is working fine, that was exactly what I wanted to do... thanks, mate. \$\endgroup\$ – torpedete Dec 10 '15 at 11:05
  • \$\begingroup\$ You're welcome! action_type and object_type you need to replace with your actual action and object type from your application on Facebook. You can read more about that here: developers.facebook.com/docs/opengraph/getting-started, but there's more work involved to set it up than second approach. \$\endgroup\$ – ruffntumble Dec 10 '15 at 19:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.