September 6, 201115 yr Hey I'm attempting to use the facebook like button integration for my website the problem is I need to put the current page being displayed's URL into the code to allow the facebook plugin to link to that page when clicked by a user, but as the page is being created dynamically I can't just type the URL in. How would I go about putting the current page's URL into the code when the user clicks the button? I don't want to just grab the contents of the URL box as this may allow users to change the content of it and cause problems? Thanks. Code: <iframe src="http://www.facebook.com/plugins/like.php?href=YOUR_URL" scrolling="no" frameborder="0" style="border:none; width:450px; height:80px"> </iframe>
September 6, 201115 yr If you're after the full URL of the current page including the entire querystring use: $_SERVER['REQUEST_URI'];
September 6, 201115 yr Author If you're after the full URL of the current page including the entire querystring use: $_SERVER['REQUEST_URI']; I pretty much just need the contents of the URL bar. So it can be linked to from facebook.
September 6, 201115 yr I pretty much just need the contents of the URL bar. So it can be linked to from facebook. If you place information after the .php? like so... www.example.com/page.php?id=100 You can use the following... $id = $_GET['id']; If the page may at one point not have any information after the .php? add an "isset" to the GET (good idea to do this anyway for good practice) Edited September 6, 201115 yr by Alluziion
September 6, 201115 yr as posted above use $_SERVER['REQUEST_URI'] or what about javascript... <script type="text/javascript"> document.write('<iframe src="http://www.facebook.com/plugins/like.php?href=' + window.location + '" scrolling="no" frameborder="0" style="border:none; width:450px; height:80px"></iframe>'); </script>
September 6, 201115 yr Author thanks for your replies! I'll try out a couple of them tomorrow and see which I can get going
Create an account or sign in to comment