Chuck Le Butt
Chuck Le Butt

Reputation: 48758

Posting a status message to Facebook?

There's so many questions regarding Facebook's sharer.php, but they're all out of date. At first Facebook depreciated it, but according to FB's dev documentation it's now back. (Edit: And now it's going again...?)

You used to be able to use it like this:

http://www.facebook.com/sharer/sharer.php?u=<url to share>&t=<message text>

But the documentation now only mentions this:

https://www.facebook.com/sharer/sharer.php?u=<url to share>

enter image description here

Is it possible to set some pre-entered text into the dialogue box that appears when sharing a link on Facebook?

Thanks.

Upvotes: 3

Views: 714

Answers (2)

orcaman
orcaman

Reputation: 6561

Just one small comment - while it is not possible to edit the text as the other comments say - it is possible to edit everything going on in that page if you can install a browser extension on your client's machines (you did not specify your use case so I am mentioning this just in case you are developing something that you are able to influence in the client machine level).

For example, with a chrome extension, you can inject scripts into facebook.com domain. in the extension manifest.json:

"content_scripts": [
        { 
          "matches": ["https://*.facebook.com/*",

And then this might be your contnet script, where you can play around with the text by hooking up to the markeup. This example sends out analytics (facebook sharer conversion rate) and changes some text (from "share" to "upload" to facebook):

sharer = (function () {
    var _ref = qs('ref') ? qs('ref') : 'unknown';
    function qs(name) {
        name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
        var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
        results = regex.exec(location.search);
        return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
    }
    function isSharer() {
        return location.pathname === '/sharer/sharer.php';
    }
    function bindEvents() {
        $('button[name="share"]').click(function() {
            analytics.send('fb_sharer', 'share', _ref);
        });
        $('#u_0_0').click(function() {
            analytics.send('fb_sharer', 'cancel', _ref);
        });
    }
    function changeText() {
        console.log($('.fcw').length);
        $('.fcw').text('Upload to Facebook');
    }
    function load() {
        if (!isSharer()) return;
        changeText();
        analytics.send('fb_sharer', 'view', _ref);
        bindEvents();
    }
    return {
        load: load
    }
})();

Upvotes: 2

C3roe
C3roe

Reputation: 96306

The Share dialog takes only the URL to share as parameter, nothing else (title, description, picture, …) any more. It fetches this data from the URL itself, from the Open Graph meta elements embedded into the document, or it takes a “guess” from the content if those are not present.

And even the “older” version of the Share dialog has not been taking a pre-set message parameter for a long time now – because you are not supposed to pre-fill the message in any way when sharing something, not matter what way the share actually happens. (“Not supposed to” actually meaning, Platform Policies explicitly forbid you from doing so.)

You can of course also share links via API (rather called “posting” a link then) – and because that happens in the background, the message is a parameter you specify while doing so. But the same rules apply – the message is supposed to be created by the user themselves beforehand, which effectively means they should have typed it in somewhere before. And even there it should not have been pre-filled so that they just have to press enter or click a button.

And since they announced API v2.0, all new apps will have to go through “login review” before they will be able to ask for any advanced permission (and posting a link requires one) – and with a pre-filled message in your app’s posting flow, you will definitively not get approval. Of course, you could try to “cheat” on that, and implement the pre-filling of the message only afterwards … but again, doing so is a clear violation of Platform Policies, and will get your app blocked when you are caught doing so.

And if you are planning to do this for multiple users with the same or largely similar messages, you can assume that Facebook’s algorithms will catch that quite easily.

Upvotes: 12

Related Questions