I'm trying to implement the facebook 'like' button my site, but I'm having a problem when my URL has an "&" in it. I have tried using htmlentities
, as well as urlencode
(which is the closest to working, but not quite).
I have a url like: example.com/entry.php?id=1&refer=abc
, and I url encode the entire thing for the href for the iframe for the social plugin button, which becomes: example.com%2Fentry.php%3Fid%3D1%26refer%3Dabc
Now, when I load the page with this like button, and click "like" it shows me the correct url "example.com/entry.php?id=1&refer=abc
" but then it says Error next to it, click the error message and I get this error:
The page at example/entry.php?id=1&refer=abc
could not be reached.
So for some reason it is interpreting the & as an &, how does this make any sense?
Thoughts?
What I would do is use the XFBML version and make use of the Open Graph Meta Tags so that you set the url in the og:url
meta tag and leave the href empty!
When all is done, run link over the URL Linter to clear the Facebook cache.