PHP Classes


Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in Bookmark in
  Classes of Hensel Hartmann  >  OpenGraph Reader with Template Output  >  >  Download  
Role: Example script
Content type: text/plain
Description: use the class, part of example
Class: OpenGraph Reader with Template Output
Extract and display OpenGraph data in Web pages
Author: By
Last change:
Date: 3 years ago
Size: 3,109 bytes


Class file image Download
 * @author Hensel Hartmann,
 * @version 2.0
 * @copyright Hensel Hartmann,
 * @license GPL
 * @package OpenGraphReader with Template Output
 * filename:
 * date: 2011-12-31


    the template that is used to output the data
    you can use the following placeholders:
    {url} - link to the media page
    {img width=[INT width in pixel]} ex: {img width=100} will construct a img-tag
    {text} - usually the media title or site title
    {description} - media/site description
    {sitename} - site name like "youtube"
/* */
$tpl = '
<div style="width: 440px;height:120px;border:1px solid black;overflow:hidden;">
    <div style="float: left; width: 120px;height:120px;border:0px solid black;">
        <div style="margin:10px auto;width:100px;height:100px;">
            <a href="{url}" target=="_blank">{img width=100}</a>
    <div style="width: 300px;height:120px;border:0px solid black;float: right;">
        <strong><a href="{url}" target=="_blank">{text} <small>{sitename}</small></a></strong><br />
        <div style="margin-left:12px;margin-right:18px;"><a href="{url}" target=="_blank">{description}</a></div>
/* */

$p = new opengraphreader();

/* sets the above tpl to use */
/* */

/* returns an array to work with * /
$arr = $p->getOG();
/* */

/* prints out the raw OG data and all the cleaned arrays needed for the process * /
/* */

if you need some test data..
// myspace
<meta property="og:title" content="Rosanna &amp;#40;Ausschnitt&amp;#41;" />
<meta property="og:site_name" content="Myspace" />
<meta property="og:url" content="" />
<meta property="og:image" content="" />
<meta property="og:description" />
<meta property="og:title" content="Rosanna &amp;#40;Ausschnitt&amp;#41;" />
<meta property="og:type" content="" />
<meta property="og:audio:type" content="audio/vnd.facebook.bridge" />
<meta property="og:audio" content="" />

// youtube
<meta property="og:url" content="">
<meta property="og:title" content="Numa Numa">
<meta property="og:description" content="numa">
<meta property="og:type" content="video">
<meta property="og:image" content="">
<meta property="og:video" content=";autohide=1">
<meta property="og:video:type" content="application/x-shockwave-flash">
<meta property="og:video:width" content="396">
<meta property="og:video:height" content="297">
<meta property="og:site_name" content="YouTube">