Facebook ignoring part of my query string in share URL

The facebook URL comes out as this:

https://www.facebook.com/sharer/sharer.php?u=http://example.com?share=1&cup=blue&bowl=red&spoon=green

The first & and the parameter cup (as well as the other parameters) are interpreted as part of the facebook url.

Use encodeURIComponent(), which will encode special characters like &:

shareURL = encodeURIComponent(siteURL+queryString);

In addition to Jason P's answer, sharer.php is long since deprecated.

Instead, you should use the Facebook Feed and Share dialogs: https://developers.facebook.com/docs/reference/dialogs/feed/

These offer more control over the share dialog, as well as better debugging via the Facebook Debugger.


As of October 2014, Facebook have deprecated both the sharer.php and the Facebook Feed and Share dialogs.

The current recommendation for link sharing is to use the Share Dialog:

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