So I have a Facebook webpage app, and I'm trying to use the Facebook Javascript SDK and the FB.ui function to post a custom Open Graph story on a user's wall.
I have a custom action 'Ride' and custom object 'Distance'. I am trying to post a custom story 'Ride a Distance'.
My function below is triggered on the click of a button:
function postDistanceRidden() {
FB.ui({
method: 'share_open_graph',
action_type: 'APP_NAME:ride',
action_properties: JSON.stringify({
distance:{
"og:type" : "APP_NAME:distance",
"app_id" : "APP_ID",
"og:url" : 'PUBLIC_URL',
"og:title" : "My Title",
"og:image" : "PUBLIC_IMAGE_URL",
"APP_NAME:distance_value" : "10",
"APP_NAME:distance_unit" : "miles",
},
})
}, function(response){});
}
When I click the button and run the function above, I get a Facebook popup window with the following error: "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: distance."
I'm not sure what I'm doing wrong. Furthermore, I have tried the above code with replacing my custom actions/objects with Facebook defined ones, and it worked (for example, 'liking' an 'article'). Any help would be greatly appreciated. Please tell me if I need to provide more information.
Thanks!
You need to create a "self-hosted object" and pass the url of your object.
function postMyAction() {
FB.ui({
method: 'share_open_graph',
action_type: 'APP_NAME:action',
action_properties: JSON.stringify({
object: "my_url_object"
},
})
}, function(response){});
}
And in object html:
<head>
<meta property='fb:app_id' content='app_id'/>
<meta property='og:type' content='my_app:object'/>
<meta property='og:title' content='my_object_title'/>
<meta property='og:image' content='an_image'/>
<meta property='og:url' content='self_url'/>
</head>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.