108

We have been opening a sharing popup (via window.open) with the URL like

https://www.facebook.com/sharer/sharer.php?s=100&p[title]=EXAMPLE&p[summary]=EXAMPLE&p[url]=EXAMPLE&p[images][0]=EXAMPLE 

and until some unknown point in the last month or so everything was fine.

What is happening now is; the popup dialog appears and correctly includes the Title, Description, Image and URL provided by the query string parameters, but when the post is submitted, the resulting wall post on Facebook is missing the Title, Description and Image, though it still links to the correct URL.

Does anyone know if there have been recent changes which could have suddenly stopped this from working?

Pre-empting some common responses:

  • "sharer.php URL was deprecated" - usage seemed to continue and it seemed the consensus was that it was largely considered to be sticking around - I haven't seen any specific indication that it should have suddenly ceased working - might have missed something

  • "Use JavaScript SDK/these OG meta tags" - not possible in my specific situation - just trust me ... I can explain if you REALLY want but it's really not relevant.

  • "Use the feed dialog" - not suitable due to lack of support for posting with attachments on FB pages

tdous
  • 1,599
  • 2
  • 14
  • 19
  • There is a Facebook bug logged by someone else here https://developers.facebook.com/bugs/563991033677853 so I'd suggest anyone else with the issue helps flag this with FB by going there and confirming that you also have this problem. – tdous Jan 06 '14 at 23:54
  • UPDATE for anyone experiencing the same problem... Other people who reported this as a bug to Facebook weren't so hot at providing detail up front or responding to information, so I resubmitted a new bug report and it's been assigned to a developer. Just waiting to hear news from FB. https://developers.facebook.com/x/bugs/357750474364812/ – tdous Jan 21 '14 at 14:53
  • 4
    Sadly, the accepted answer is right. After 3 months of waiting for the bug to be "fixed" they changed the accepted behaviour of sharer.php so these parameters can no longer be used. – tdous May 05 '14 at 22:40

5 Answers5

110

Facebook no longer supports custom parameters in sharer.php

The sharer will no longer accept custom parameters and facebook will pull the information that is being displayed in the preview the same way that it would appear on facebook as a post from the url OG meta tags.

Use dialog/feeds instead of sharer.php

https://www.facebook.com/dialog/feed?
  app_id=145634995501895
  &display=popup&caption=An%20example%20caption 
  &link=https%3A%2F%2Fdevelopers.facebook.com%2Fdocs%2Fdialogs%2F
  &redirect_uri=https://developers.facebook.com/tools/explorer

Official answer from fb team

Shankar Narayana Damodaran
  • 68,075
  • 43
  • 96
  • 126
jsnjack
  • 2,630
  • 2
  • 21
  • 21
  • 1
    Beat me to answering my own question ;) – tdous Apr 10 '14 at 12:00
  • 35
    but you need an app id in this case. What if it's just a website? – German Capuano May 27 '14 at 00:55
  • 3
    From Facebook: The Feed Dialog for web has been deprecated in API Version 2.0. On web, developers are encouraged to use the more modern Share Dialog, which can perform all of the same functions as these older dialogs, but can additionally publish custom Open Graph stories without requiring Facebook Login. https://developers.facebook.com/docs/sharing/reference/share-dialog – RubeOnRails Jul 28 '14 at 23:21
  • If possible, I would suggest using the Facebook SDK with JavaScript. It's much easier to code and I would consider it to be much less picky than using the link form above. Take a look at: https://developers.facebook.com/docs/sharing/web – LiquidDrummer Mar 16 '16 at 18:48
  • 18
    @LiquidDrummer the whole point of using these types of URLs is so you *don't have to use the SDK*. It adds a needless performance hit to your page, helps FB invade people's privacy and is *not* simpler than a plain `` tag or `open()` call. – Walf Feb 16 '17 at 03:07
103

Starting from July 18, 2017 Facebook has decided to disregard custom parameters set by users. This choice blocks many of the possibilities offered by this answer and it also breaks buttons used on several websites.

The quote and hashtag parameters work as of Dec 2018.


Does anyone know if there have been recent changes which could have suddenly stopped this from working?

The parameters have changed. The currently accepted answer states:

Facebook no longer supports custom parameters in sharer.php

But this is not entirely correct. Well, maybe they do not support or endorse them, but custom parameters can be used if you know the correct names. These include:

  • URL (of course) → u
  • custom image → picture
  • custom title → title
  • custom quote → quote
  • custom description → description
  • caption (aka website name) → caption

For instance, you can share this very question with the following URL:

https://www.facebook.com/sharer/sharer.php?u=http%3A%2F%2Fstackoverflow.com%2Fq%2F20956229%2F1101509&picture=http%3A%2F%2Fwww.applezein.net%2Fwordpress%2Fwp-content%2Fuploads%2F2015%2F03%2Ffacebook-logo.jpg&title=A+nice+question+about+Facebook&quote=Does+anyone+know+if+there+have+been+recent+changes+which+could+have+suddenly+stopped+this+from+working%3F&description=Apparently%2C+the+accepted+answer+is+not+correct.

Try it!

I've built a tool which makes it easier to share URLs on Facebook with custom parameters. You can use it to generate your sharer.php link, just press the button and copy the URL from the tab that opens.

bilalq
  • 7,279
  • 3
  • 22
  • 28
Andrea Lazzarotto
  • 2,471
  • 1
  • 22
  • 38
  • 2
    Thanks a lot, that's great! – Nightmare_82 Dec 03 '16 at 22:26
  • Great answer! Thanks a lot! – Andrei Mar 06 '17 at 19:31
  • Nice! Can I customize the message of sender? – Zsolt Takács May 09 '17 at 10:21
  • @TakácsZsolt I do not think it's possible to pre-fill that message, but if you find a way please let me know. – Andrea Lazzarotto May 09 '17 at 18:34
  • @AndreaLazzarotto with this solution you can, but you have to use encodeURIComponent() js function every part of given parameter. But you can't customise the official Share button :/ – Zsolt Takács May 30 '17 at 14:01
  • 1
    @TakácsZsolt You don't need JS on the page, you can just generate the URL server-side in your CMS or custom code and then serve the user a simple URL. The official share button is bad because it includes tons of KB of JS code *and it tracks users.* Also, if you are sharing your own URLs you'd better serve proper OpenGraph tags instead of relying on the Facebook sharer parameters. :) – Andrea Lazzarotto May 30 '17 at 14:29
  • I used to implement the buttons in this way. Always worked but stopped for now. July 2017. Are there any news concerning this? – Garavani Jul 27 '17 at 06:48
  • 1
    @Garavani, yes you are right. As discussed on the comments of the tool, they have deprecated the parameters and removed them. – Andrea Lazzarotto Jul 27 '17 at 14:12
  • Check Hannes’ answer here: https://stackoverflow.com/questions/23781698/fb-ui-share-set-the-title-message-and-image/45262736#comment79095652_45262736 It worked for me. Even after July 2017. – Garavani Sep 07 '17 at 08:25
  • @Garavani, yes one can create their own app and inject the Facebook JS (which is not lightweight and tracks users). But can a simple URL be composed? According to the docs, it doesn't seem so. – Andrea Lazzarotto Sep 07 '17 at 11:33
  • To be honest I have no idea about Facebook apps, tracking etc. Sounds not so cool. As it seems (I googled a lot), no, a simple url with parameters does not work any longer, as you stated by yourself. I implemented Hannes’ solution though. And don’t think even about Google+ … The whole custom share issue becomes more and more a pain. Guess this is why it seems to simply disappear on many websites. It’s a pity because it is a great tool to spread content. – Garavani Sep 07 '17 at 12:45
  • @Andrea: Is there a experience difference for the user between the share that you (we) had before with parameter link and the obstrusive but working solution I cited above? – Garavani Sep 07 '17 at 16:15
  • @Garavani, unfortunately, there is. See for instance [(1)](https://www.christian-schneider.net/TrackingBySocialNetworks.html) [(2)](https://lastdropofink.co.uk/market-places/the-true-cost-of-adding-social-buttons/) [(3)](http://jcux.co.uk/posts/buttons.html) [(4)](http://www.ericmobley.net/social-media-share-buttons-impact-on-performance/) [(5)](https://cloudcannon.com/tutorials/2017/02/01/lightweight-social-share-buttons/). I wish there wasn't though, because it would be a lot easier. – Andrea Lazzarotto Sep 07 '17 at 18:37
  • @Andrea: thanks for the awesome and well collected information! I am thinking to throw them out. Damn Facebook. – Garavani Sep 08 '17 at 04:58
  • @Garavani you are welcome. A middle-ground solution could be the good ol' Social Share Privacy project: https://panzi.github.io/SocialSharePrivacy/ – Andrea Lazzarotto Sep 08 '17 at 12:29
  • @Andrea: you may also check out how they did it (even for singular slides) look below on this page: http://www.chanel.com/en_WW/fashion/collection/paris-cosmopolite-mda-2016-17-show-ritz-paris.html – Garavani Sep 09 '17 at 04:43
  • 5
    As of April 2018 it seems any parameters other than `u` are silently ignored. – leo Apr 25 '18 at 10:03
  • 2
    Other than `u` the only parameter I see reflected is `quote` – robskrob Sep 10 '18 at 20:54
  • @robskrob did you read the gigantic notice that was added to this answer some months after it was written? – Andrea Lazzarotto Sep 12 '18 at 09:42
  • 1
    @AndreaLazzarotto I did read the notice and rereading it now I see the following `The quote parameters still works` which was not in bold. I suppose I missed it. Also in the spirit of productive dialogue, I've been able to customize a facebook share (image, title, description etc) by adjusting the `og:#{property}` in each page's `meta` tag as specified here in the facebook documentation: https://developers.facebook.com/docs/plugins/share-button/ -- so if anyone is looking to have more control over how their FB shares looks I recommend clicking on the share button link above in this comment. – robskrob Sep 17 '18 at 14:21
  • I can confirm the quote and hashtag parameters still working in january 2020. I'm using this for sharing links to PDF documents because Facebook cannot read the PDF title and the URL may not always convey the actual title of the PDF. Another (ugly) workaround would be to link to a special download link which would be a page with an og:title and og:image set which could have the actual download link. – Spellcoder Jan 27 '20 at 10:09
  • @Spellcoder recently I found a special offer for a lifetime account of a third party service that does exactly that. I won't link to it as it might be considered spam. It's called Poplink but there are several marketing services that work similarly. – Andrea Lazzarotto Jan 27 '20 at 11:10
  • `quote` parameter is no longer working. – joseantgv Feb 15 '23 at 12:16
3

Your problem is caused by the lack of markers OpenGraph, as you say it is not possible that you implement for some reason.

For you, the only solution is to use the PHP Facebook API.

  1. First you must create the application in your facebook account.
  2. When creating the application you will have two key data for your code:

    YOUR_APP_ID 
    YOUR_APP_SECRET
    
  3. Download the Facebook PHP SDK from here.

  4. You can start with this code for share content from your site:

    <?php
      // Remember to copy files from the SDK's src/ directory to a
      // directory in your application on the server, such as php-sdk/
      require_once('php-sdk/facebook.php');
    
      $config = array(
        'appId' => 'YOUR_APP_ID',
        'secret' => 'YOUR_APP_SECRET',
        'allowSignedRequest' => false // optional but should be set to false for non-canvas apps
      );
    
      $facebook = new Facebook($config);
      $user_id = $facebook->getUser();
    ?>
    <html>
      <head></head>
      <body>
    
      <?php
        if($user_id) {
    
          // We have a user ID, so probably a logged in user.
          // If not, we'll get an exception, which we handle below.
          try {
            $ret_obj = $facebook->api('/me/feed', 'POST',
                                        array(
                                          'link' => 'www.example.com',
                                          'message' => 'Posting with the PHP SDK!'
                                     ));
            echo '<pre>Post ID: ' . $ret_obj['id'] . '</pre>';
    
            // Give the user a logout link 
            echo '<br /><a href="' . $facebook->getLogoutUrl() . '">logout</a>';
          } catch(FacebookApiException $e) {
            // If the user is logged out, you can have a 
            // user ID even though the access token is invalid.
            // In this case, we'll get an exception, so we'll
            // just ask the user to login again here.
            $login_url = $facebook->getLoginUrl( array(
                           'scope' => 'publish_stream'
                           )); 
            echo 'Please <a href="' . $login_url . '">login.</a>';
            error_log($e->getType());
            error_log($e->getMessage());
          }   
        } else {
    
          // No user, so print a link for the user to login
          // To post to a user's wall, we need publish_stream permission
          // We'll use the current URL as the redirect_uri, so we don't
          // need to specify it here.
          $login_url = $facebook->getLoginUrl( array( 'scope' => 'publish_stream' ) );
          echo 'Please <a href="' . $login_url . '">login.</a>';
    
        } 
    
      ?>      
    
      </body> 
    </html>
    

You can find more examples in the Facebook Developers site:

https://developers.facebook.com/docs/reference/php

Andrea
  • 11,801
  • 17
  • 65
  • 72
Joseph Collins
  • 441
  • 2
  • 9
  • 3
    You're right Joseph, and I hope the information you've provided is useful to someone who finds this page. Because of that I've voted it up. I have only not marked it as the answer because we already knew that we would have to fall back to PHP if Facebook did not revert the changes they've made. The complete solution I'd hope for, a way to use the sharer URL is a similar way to how it used to work, may not exist now or in the future. But thanks for your response and I trust it'll be useful to someone in this situation. – tdous Mar 17 '14 at 14:05
2

I review your url in use:

https://www.facebook.com/sharer/sharer.php?s=100&p[title]=EXAMPLE&p[summary]=EXAMPLE&p[url]=EXAMPLE&p[images][0]=EXAMPLE

and see this differences:

  1. The sharer URL not is same.
  2. The strings are in different order. ( Do not know if this affects ).

I use this URL string:

http://www.facebook.com/sharer.php?s=100&p[url]=http://www.example.com/&p[images][0]=/images/image.jpg&p[title]=Title&p[summary]=Summary

In the "title" and "summary" section, I use the php function urlencode(); like this:

<?php echo urlencode($detail->title); ?>

And working fine for me.

Joseph Collins
  • 441
  • 2
  • 9
  • Is it still working on your side ? When I try your example URL, I'm not getting the title and summary displayed ! – vcarel Feb 28 '14 at 06:39
  • 1
    @vcarel This only works with OpenGraph, that's the problem. Post a different method in another answer. – Joseph Collins Feb 28 '14 at 14:55
  • @JosephCollins In response to your differences: 1. The URL "hxxp://facebook.com/sharer.php" just redirects to "hxxp://facebook.com/sharer/sharer.php", I assume to be backwards compatible with a previous sharing feature. 2. The order of fields makes no difference. I did try your order just in case, still a problem. As I said in my original question, this did work correctly, then one day it did not with no changes at our end. It's been accepted as a bug by Facebook, so it's not just a URL format issue. But they're certainly taking their sweet time doing anything about it. – tdous Feb 28 '14 at 15:14
-1

If you encode the & in your URL to %26 it works correctly. Just tested and verified.