PHP Classes

File: ExampleUsage.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in Bookmark in
  Classes of Hensel Hartmann  >  OpenGraph Reader with Template Output  >  ExampleUsage.php  >  Download  
File: ExampleUsage.php
Role: Auxiliary data
Content type: text/plain
Description: a primitve facebook like wall
Class: OpenGraph Reader with Template Output
Extract and display OpenGraph data in Web pages
Author: By
Last change:
Date: 3 years ago
Size: 3,239 bytes


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

fieldset { margin-bottom: 1em; }
input { display: block; margin-bottom: .25em; }
#print-output {
  width: 100%;
.print-output-line {
  white-space: pre;
  padding: 5px;
  font-family: monaco, monospace;
  font-size: .7em;

  <script src=""></script>

<h1 style="margin-bottom:6px;">usage demo of class.opengraphreader.php</h1>
<strong>This shows the basics of replicating the behaviour of the Facebook wall.</strong>
<br /><br />
    <fieldset style="width: 900px;">
        <div style="float: right;">
            try one of these:<br />
            <br />
            <br />
            <br />
            <br />
            <br />
            <br />
        <div style="width: 350px;">
            In this demo, only one URL (the  first) will be gathered!<br />
            You can easely adjust the js to get all urls parsed<br />
            The script runs on "keyup"!
            But if "it" happened, an url was found in the text, the script stops - so it will not process the URL over and over again..<br />
            In this Demo, you can clear that cache. <br />
            To release the "cache", click the button "clear og cache and refresh preview" below<br /><br />
            <label for="target">Type something and use an url in text, that leads to an open graph enabled site:</label>
            <table border="1"><tr>
                <textarea id="target" style="width: 650px;height: 100px;border:1px solid #707070;"></textarea>
                <div id="result_cont"></div>

<button id="other">clear og cache and refresh preview</button>


geturl = new RegExp(
          "(^|[ \t\r\n])((http|https):(([A-Za-z0-9$_.+!*(),;/?:@&~=-])|%[A-Fa-f0-9]{2}){2,}(#([a-zA-Z0-9][a-zA-Z0-9$_.+!*(),;/?:@&~=%-]*))?([A-Za-z0-9$_+!*();/?:~-]))"
var cache=0;
    var string = $('#target').val();
    if(string.match(geturl) === null)
    var url = string.match(geturl)[0];
    if(!url){ url = string.match(geturl); }
    if(string.match(geturl).length>0 && !cache)

$('#other').click(function() {