Basically I'm trying to pass a URL like this:
www.foobar.com/?first=1&second=12&third=5
into a URL like this:
http://www.facebook.com/sharer.php?&t=FOOBAR&u=http://www.foobar.com/first=12&sec=25&position=2
It only recognizes the first parameter. I'm having the same problem with LinkedIn and Twitter sharing, so it must be something I'm doing wrong.
$vars = array('email' => $email_address, 'event_id' => $event_id); $querystring = http_build_query($vars); $url = "http://localhost/main.php?" . $querystring; Additionally, if $event_id is in your session, you don't actually need to pass it around in order to access it from different pages.
What triggers this issue? There are internal URLs in the web resource that contain multiple ampersands (“&”) and, consequently, multiple parameters.
Although officially there is no limit specified by RFC 2616, many security protocols and recommendations state that maxQueryStrings on a server should be set to a maximum character limit of 1024.
Rather than html encoding
your URL parameter, you need to URL encode
it:
http://www.facebook.com/sharer.php?&t=FOOBAR&u=http%3A%2F%2Fwww.foobar.com%2F%3Ffirst%3D12%26sec%3D25%26position%3D
You can do this easily in most languages - in javascript:
var encodedParam = encodeURIComponent('www.foobar.com/?first=1&second=12&third=5'); // encodedParam = 'http%3A%2F%2Fwww.foobar.com%2F%3Ffirst%3D12%26sec%3D25%26position%3D'
(there are equivalent methods in other languages too)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With