Ajax30 Posted May 31, 2017 Share Posted May 31, 2017 On this page I have a bunch of mp3 files displayed as nicely styled boxes. Each box has a Facebook share button. I would like to add each boxes id (mp3jWrap_0, mp3jWrap_1, etc) as hash to its Facebook share link so that every time a shared item is visited from Facebook, the URL contains the item's hash. For this purpose I have written the code: <?php $actual_link = (isset($_SERVER['HTTPS']) ? "https" : "http") . "://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; $actual_link = trim($actual_link, '/'); $actual_link = $actual_link . '#mp3jWrap_' . $id; echo '<li class="fb_share"><a href="http://www.facebook.com/sharer.php?u="' . $actual_link . '" title="Share on Facebook" target="_blank"><i class="fa fa-facebook"></i></a></li>'; ?> The problem: the string after the hash (with hash included) is not in the URL when you click the share button. Why? Quote Link to comment Share on other sites More sharing options...
requinix Posted May 31, 2017 Share Posted May 31, 2017 You're creating a link like http://www.facebook.com/sharer.php?u=https://www.example.com/somewhere#mp3jWrap_123Just like every other link, if you put a # in it then you're going to an anchor on that page. There is no "mp3jWrap_123" on that Facebook page. Encode the URL. You also messed up the quotes - look at your use of "s. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.