如何动态更改og:我的页面标题

Essentially I have a website, which uses a query string to dynamically change the content depending on what the user enters into the url. I have also used a .htaccess file to rewrite the url to remove the question mark, so it looks like just another page. Example:

www.site.com/233 - loads content associated with the ID 233

My problem is that when someone likes the page on facebook, although I have used JS to change the url of the like to the current page, there is no way I can see (within my current coding ability) to dynamically change the og:url og:title etc. with the query string.

The outcome I want is that when someone likes my page, it shows on the news feed what content the user has liked. Example

user liked www.site.com/231 - instead of it showing just 'site' in the newsfeed
I wish it to show the extention, i.e 'site - content 231' for /231 and 'site -
content 4234' for /4234

Currently I have been forced to set a basic og:title and no og:url because obviously it is the same for each extension to the query string.

Simples explanation of my comment:

// router.php

// process URL and blah blah blah here

$config = array(
     "og" => array(
         "title" => "Cool Page"
     )
);
include 'template.php';


// template.php
<html>
    <head>
        <title><?php echo $config["og"]["title"]; ?></title>
    </head>
    <body>
    </body>
</html>