I have a website. I need to share content on facebook. I had created custom story "Participate in a Engagement" with respective action "Participate" and object "Engagement".My problem is to get explicitly_shared permission from facebook,I need to show user what is going to posted. When i am posting using FB.api like below, it is posting successfuly. Approach 1 :
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({
appId : "Some App ID",
status : true,
cookie : true,
xfbml : true,
version : 'v2.0',
});
};
// Load the SDK Asynchronously
(function(d, s, id){
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {return;}
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
function postFBShare() {
var fbparam= {
"app_id":"Some App ID",
"url":"Some url",
"title":'Some Title',
"image":[
{url:"Some image url"}
],
"description":'',
"explicitly_shared": "true"
};
FB.api(
'https://graph.facebook.com/me/{namespace}:participate ',
'post',
{
engagement: fbparam
},
function(response) {
// handle the response
}
);
}
</script>
<input type="button" value="fb share" onclick="postFBShare();">
Approach 2: but to show user wht is going to post i need an object to post.I wrote the following code to achieve this.
function preFBAction(videoURL){
var fbparam= {
"app_id":"Some App ID",
"type" : {namespace}:engagement,
"url":"Some url",
"title":'Some Title',
"image":[
{url:"Some image url"}
],
"description":'',
"explicitly_shared": "true"
};
FB.api(
'/app/objects/{namespace}:engagement',
'post',
{
engagement: fbparam
},
function(response) {
// handle the response
if (response && !response.error) {
FB.ui(
{
method: 'share_open_graph',
action_type: '{namespace}:participate ',
action_properties: JSON.stringify({engagement:response.id})
},
function(response) {
// handle the response
}
);
}
}
);
};
Approach 3: I tried with using only FB.ui,but getting following error in share dialog "Action Requires At Least One Reference: The action you're trying to publish is invalid because it does not specify any reference objects. At least one of the following properties must be specified: other." The code I tried is-
var obj={
method: 'share_open_graph',
action_type: '{namespace}:participate ',
action_properties: {engagement:fbparam}
};
FB.ui(obj,function(response) {
// handle the response
});
So if someone know how to do this and where I am going wrong, help out. Thanks!!
UPDATE
Using og tags on public page I am able to post on wall successfully and as well as in Approach 2 if I use "/me/objects/.." in place of "/app/objects.." Post gto posted on facebok but this time i got created in newz feed as well as activity log, which is not according to facebook policies.(similiar problem mentioned here.)