Facebook share message in cocos2d-js-v3.0

Hello,

Am using latest cocos2d-Js-v3.0. Am trying to share message on facebook.

Following is the code am using to share.

var map = {
“dialog”: “share_link”,
“description”: “Cocos2d-JS is a great game engine”,
“title”: “Cocos2d-JS”,
“link”: “http://www.cocos2d-x.org”,
“imageUrl”: “http://files.cocos2d-x.org/images/orgsite/logo.png
};
facebook.share(map, function (resultcode, msg) {
cc.log(JSON.stringify(msg));
});

When i run using this code, On share message icon image and description will be taken based on url link. I want to share my own description and image. If i change the description and imageUrl, then there is no change in share message.

Can anyone please help me out.

Thanks and regards
Gurudath

You need to use .dialog API

Hello,

Am trying out with .dialog api. Its asking to login to facebook. After login am not getting any share message.

This is code am using.
var map = {
“dialog”: “share_open_graph”,
“action_type”: “cocostestmyfc:share”,
“preview_property”: “cocos_document”,
“title”: “Cocos2d-JS Game Engine”,
“image”: “http://files.cocos2d-x.org/images/orgsite/logo.png”,
“url”: “http://cocos2d-x.org/docs/manual/framework/html5/en”,
“description”: “cocos document”
};
facebook.dialog(map, function (resultcode, msg) {
cc.log(JSON.stringify(msg));
});

If any mistake in code please let me know.

Thanks

There is no problem, but as you are sharing a OpenGraph action defined in our test app, and your FB account is not a test account of our app, it won’t make any effect.
You can:

  1. Create your own test app and actions, reconfig the app and test out
  2. Share a link or a photo won’t produce any problem

Am new to this platform. I have created test account in facebook. Am using created id for the app. I want to share my score as message in facebook.

Am facing trouble in understanding. should i use share api of dialog api?

Thanks

You should use dialog API, share API is a alias for simple link sharing.
And about configurations you can refer to our documentation

Okay. I will check and let you know.

Thanks for the reply

Hi.

Am trying to share message in facebook. If i use dialog api with share link method,am not able to connect facebook.

AM reading below document and trying to share message.
http://www.cocos2d-x.org/docs/manual/framework/html5/facebook-sdk/api-reference/dialog-share

I have seen facebook UI reference on below link
https://developers.facebook.com/docs/sharing/reference/share-dialog

As per this link facebook support only two methods i.e share method and share-open-graph method.

Is share link method works?

Thank you

share_link should work without problem, have you tried it?

Ya i tried it. Its not working for me. FB page is not connecting itself. When i check with fb.ui facebook documentation am not able to see share_link method.

It’s not on Facebook’s official documentation yet, fb.ui doesn’t equal to our .dialog API, please refer to our documentation. And can you try to .login first to let user login ? Thanks!

http://www.cocos2d-x.org/docs/manual/framework/html5/facebook-sdk/api-reference/dialog-share

I have looked into same documentation. U can see above i mentioned same link. I copied code from the documentation. AM not able to connect facebook using .dialog api. share api works fine for me

How did you use “share_link” ? Can you post updated code you are using ?

Here is code am using to share

var info = {
    "dialog": "share_link",
    "description": “Sample”,
    "title": “Game,
    "link": "http://54.235.87.120/FacebookTest/faceBookLink3.html",
    "imageUrl": "http://files.cocos2d-x.org/images/orgsite/logo.png"
};
facebook.dialog(info, function (code, response) {
    if(code == plugin.FacebookAgent.CODE_SUCCEED){
        // Succeed
    } else {
        cc.log("Sharing failed, error #" + code + ": " + response);
    }
});

I found some typo error in your code,

The quote you are using are not the correct one, and the title content haven’t been completed with quote, normally, you should receive errors like: SyntaxError: Invalid character '\u8220'

Are you receiving other errors ?

Am not getting error. For me facebook window try to opens but its not opening. window will be in redirecting state.