Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add custom name, caption, image, description to new facebook share dialog or custom stories not taking them from og meta

I'm just working on a quiz script. Thus I want to share the results of an quiz and not the og meta data.

I know it is possible to use the old FB.ui feed action do add a custom name, caption, description and message than sharing an url. E.g.:

    FB.ui({
    method: 'feed',
    href: url,
    name: name,
    caption: title,
    description: des,
    message: message,
    picture: img,
}, function(response){});

However I think this gonna be deprecated soon?!

Is this possible with the new share api too? Or can I do this with custom stories? How? I'm looking for something like

    FB.ui({
    method: 'share',
    href: url,
    name: name,
    caption: title,
    description: des,
    message: message,
    picture: img,
}, function(response){});

But this isn't working :/ it only takes the href. Everything else is ignored and not prefilled :(

Is there any best practise or a facebook recommended way to do this?

API docs: https://developers.facebook.com/docs/sharing/reference/share-dialog

Thx. I really appreciate your help

like image 521
Manuel Avatar asked May 28 '14 13:05

Manuel


People also ask

What is a Facebook meta tag?

You can optionally set metadata tags in your product feed files. This enables Facebook to attribute catalogs using this feed to your app. Once a catalog is attributed to your app, the meta tag is not required in subsequent feed uploads to that catalog.


2 Answers

Update on 2019. This method is not working any more. New solution has not been find yet. :(

Update on 27.06.2018. Old version of the code stopped working properly. The shared image was displayed as small image on the left, instead of as large full column image. The fix is to replace action_type: 'og.shares' with action_type: 'og.likes'.

Use this code:

    FB.ui({
    method: 'share_open_graph',
    action_type: 'og.likes',
    action_properties: JSON.stringify({
        object: {
            'og:url': url,
            'og:title': title,
            'og:description': des,
            'og:image': img
        }
    })
},
function (response) {
// Action after response
});

This works with API version 2.9+. Please note that using og.shares action_type, is not advised any more since it is not mentioned in the FB documentation and it doesn't properly display the large image. I now use og.likes. The small downside is the sentence like "John Doe likes the object on drib" near the top of share dialog and shared content on user wall.

For full working example checkout Dynamically change Facebook open graph meta data with JavaScript.

like image 96
DamirR Avatar answered Sep 23 '22 09:09

DamirR


I have no idea where these parameters are documented for the Share dialog, but I had a guess, and these all work. As a tip, change the 'name' parameter you were using in the Feed method to 'title'. I am custom sharing from multiple share buttons on a single web page. Obviously, replace all the 'custom...' variables with your own variables or 'string':

FB.ui({
        method: 'share',
        href: 'http://yourwebpage.com',
        picture: customImage,
        title: customTitle,
        description: customDescription,
        caption: customCaption

    }, function(response) {});
like image 35
spacewindow Avatar answered Sep 23 '22 09:09

spacewindow