I tried to implement this code on my page, and all that it did was publish the story again, outside of the .css styling. It did not publish the title or description. Could you clarify your instructions please?
By printing the Array to your web page (print_r as seen above), you can see the keys some of which has the sufficient information for eg. title, description, full story... etc. Some of the strings you have to parse with PHP to get what you want.
For example here is the code I'm using, $entry['t'] will print the title without the need of parsing the string, $entry['s'] has the short story and $entry['f'] contains the full story. I have fetched them with cn_api.php and then with some functions I have parsed them to what I want from the strings in question.
require_once 'cutenews/cn_api.php';
$entry = cn_api_get_entry();
if ($entry['t'])
{
// ........
$header_title = $entry['t'];
$str = $entry['s'];
$rawdesc = $entry['f'];
function get_string_between($string, $start, $end){
$string = " ".$string;
$ini = strpos($string,$start);
if ($ini == 0) return "";
$ini += strlen($start);
$len = strpos($string,$end,$ini) - $ini;
return substr($string,$ini,$len);
}
function stripBBCode($text_to_search) {
$pattern = '|[[\/\!]*?[^\[\]]*?]|si';
$replace = '';
return preg_replace($pattern, $replace, $text_to_search);
}
$rawdesc2 = stripBBCode($rawdesc);
$pattern = "/[a-zA-Z]*[:\/\/]*[A-Za-z0-9\-_]+\.+[A-Za-z0-9\.\/%&=\?\-_]+/i";
$replacement = "";
$sdesc = preg_replace($pattern, $replacement, $rawdesc2);
$fdesc = strip_tags($sdesc);
$image = get_string_between($str, "[img]", "[/img]");
echo "<title>".$header_title."</title>\n";
echo "<meta property=\"og:title\" content=\"".$header_title." \" />";
echo "<meta property=\"og:image\" content=\"http://hcmeanmachine.com/cutenews/uploads/".$image."\"/>";
echo "<meta property=\"og:description\" content=\"".$fdesc."\" />";
} else {
echo "<title>Masiina » Uutiset</title>\n";
echo "<meta property=\"og:title\" content=\"Masiina » Uutiset\" />";
}