GarethW Posted February 11, 2014 Share Posted February 11, 2014 Hi,I'm trying to pass a variable from my php script on the page into the og;metadata, but on the timeline all that is shown is the standard html metadata, am I using the correct php code to call the variable so that it shows up on the timeline? <meta property="og:title" content="<?php $_GET['$title']; ?>"/>the title variable comes from here; $title = urlencode("Take The Test!");Any help on this is much appreciated, Gareth Quote Link to comment https://forums.phpfreaks.com/topic/286122-newbie-calling-php-variables-within-opengraph-meta-data-for-facebook/ Share on other sites More sharing options...
ginerjm Posted February 11, 2014 Share Posted February 11, 2014 Your first statement implies that the value comes from a url query string while your second line merely sets a local variable to a value. These are in no way connected. Quote Link to comment https://forums.phpfreaks.com/topic/286122-newbie-calling-php-variables-within-opengraph-meta-data-for-facebook/#findComment-1468538 Share on other sites More sharing options...
Mancent Posted February 12, 2014 Share Posted February 12, 2014 you could echo <meta property="og:title" content="<?php echo $_GET['$title']; ?>"/> Quote Link to comment https://forums.phpfreaks.com/topic/286122-newbie-calling-php-variables-within-opengraph-meta-data-for-facebook/#findComment-1468556 Share on other sites More sharing options...
GarethW Posted February 13, 2014 Author Share Posted February 13, 2014 Thanks @ginerjm, and @Mancent, I realised that the Opengraph method is not the way to go (cacheing issues), I was wondering if you could help on this hopefully simple question, is it possible (or have I got the wrong syntax) to pass e.g. '$title' etc into an array: $params = array( "caption" => "$title", "description" => "$text"); From $title = urlencode("My Sample Title Title"); $text = urlencode("My Sample Description Text"); Again, any help is much appreciated, Gareth Quote Link to comment https://forums.phpfreaks.com/topic/286122-newbie-calling-php-variables-within-opengraph-meta-data-for-facebook/#findComment-1468786 Share on other sites More sharing options...
ginerjm Posted February 13, 2014 Share Posted February 13, 2014 Nothing wrong with that code. Quote Link to comment https://forums.phpfreaks.com/topic/286122-newbie-calling-php-variables-within-opengraph-meta-data-for-facebook/#findComment-1468787 Share on other sites More sharing options...
Solution GarethW Posted February 25, 2014 Author Solution Share Posted February 25, 2014 Thanks @ginerjm, yes it did work, but has lead me on to more problems, but will post a different thread, thanks again. Quote Link to comment https://forums.phpfreaks.com/topic/286122-newbie-calling-php-variables-within-opengraph-meta-data-for-facebook/#findComment-1470663 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.