Permalink
Browse files

PHP version (no framework)

  • Loading branch information...
1 parent 4b2f810 commit 0a035720e21b9eaaa6e107a5c18cc1b708daf413 @elcio elcio committed Mar 14, 2011
Showing with 59 additions and 0 deletions.
  1. 0 php/cache/.cache
  2. +14 −0 php/cacheurl.php
  3. +5 −0 php/index.php
  4. +40 −0 php/template/index.php
View
0 php/cache/.cache
No changes.
View
14 php/cacheurl.php
@@ -0,0 +1,14 @@
+<?
+
+if(!defined('CACHE_DIR'))define('CACHE_DIR','cache/');
+
+function cacheURL($url,$timeout){
+ $key=md5($url);
+ if(file_exists(CACHE_DIR.$key) and (filemtime(CACHE_DIR.$key) + $timeout) > time()){
+ return file_get_contents(CACHE_DIR.$key);
+ }else{
+ $t=file_get_contents($url);
+ file_put_contents(CACHE_DIR.$key,$t);
+ return $t;
+ }
+}
View
5 php/index.php
@@ -0,0 +1,5 @@
+<?
+require_once('cacheurl.php');
+$fml_endpoint='http://graph.facebook.com/search?q=so%20starving&type=post';
+$fb_data=json_decode(cacheURL($fml_endpoint,30*60));
+include('template/index.php');
View
40 php/template/index.php
@@ -0,0 +1,40 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+ "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+ <title>FMl</title>
+ <style>
+ .author{
+ font-style:italic;
+ }
+ li{
+ list-style: none;
+ }
+ .picture, .message{
+ float:left;
+ }
+ </style>
+</head>
+<body>
+
+
+ <ul>
+ <?foreach($fb_data->data as $post):?>
+ <?if(isset($post->message)):?>
+ <li>
+ <div>
+ <div class="picture">
+ <img src="https://graph.facebook.com/<?=$post->from->id?>/picture" />
+ </div>
+ <div class="message">
+ <?=$post->message?> : <span class="author"><?=$post->from->name?></span>
+ </div>
+ </div>
+ </li>
+ <?endif?>
+ <?endforeach?>
+ </ul>
+
+
+</body>
+</html>

0 comments on commit 0a03572

Please sign in to comment.