PHP Classes

File: ExampleUsage.php

Recommend this page to a friend!
  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: 11 years ago
Size: 3,239 bytes


Class file image Download
<!DOCTYPE html> <html> <head> <!-- /* * @author Hensel Hartmann, * @version 2.0 * @copyright Hensel Hartmann, * @license GPL * @package OpenGraphReader with Template Output * filename: * date: 2011-12-31 * */ --> <style> 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; } </style> <script src=""></script> </head> <body> <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 /> <form> <fieldset style="width: 900px;"> <div style="float: right;"> try one of these:<br /> <br /> <br /> <br /> <br /> <br /> <br /> </div> <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> </div> <table border="1"><tr> <td> <textarea id="target" style="width: 650px;height: 100px;border:1px solid #707070;"></textarea> <div id="result_cont"></div> </td> </tr></table> </fieldset> </form> <button id="other">clear og cache and refresh preview</button> <script> 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$_+!*();/?:~-]))" ,"g" ); var cache=0; $('#target').keyup(function(event){ var string = $('#target').val(); if(string.match(geturl) === null) { return; } var url = string.match(geturl)[0]; if(!url){ url = string.match(geturl); } if(string.match(geturl).length>0 && !cache) { jQuery('#result_cont').load(''+url); cache=1; } }); $('#other').click(function() { cache=0; $('#target').keyup(); }); </script> </body> </html>