aboutsummaryrefslogtreecommitdiffstats
path: root/include/oembed.php
diff options
context:
space:
mode:
authorFabio Comuni <fabrix.xm@gmail.com>2011-01-31 17:23:55 +0100
committerFabio Comuni <fabrix.xm@gmail.com>2011-01-31 17:23:55 +0100
commitbdbbfe17b0ab58a89a0673f5409d30870afd0b9d (patch)
tree0e2644a6a5ebfad99fb5c42fadac3522a83e70ee /include/oembed.php
parent3dbca2a8041540a9e8a336db21fc28fc3b6bc5d7 (diff)
downloadvolse-hubzilla-bdbbfe17b0ab58a89a0673f5409d30870afd0b9d.tar.gz
volse-hubzilla-bdbbfe17b0ab58a89a0673f5409d30870afd0b9d.tar.bz2
volse-hubzilla-bdbbfe17b0ab58a89a0673f5409d30870afd0b9d.zip
cache oembed request
Diffstat (limited to 'include/oembed.php')
-rw-r--r--include/oembed.php16
1 files changed, 14 insertions, 2 deletions
diff --git a/include/oembed.php b/include/oembed.php
index f9441b370..a130357ab 100644
--- a/include/oembed.php
+++ b/include/oembed.php
@@ -1,8 +1,20 @@
<?php
function oembed_replacecb($matches){
$embedurl=$matches[1];
- $ourl = "http://oohembed.com/oohembed/?url=".urlencode($embedurl);
- $txt = fetch_url($ourl);
+
+ $r = q("SELECT v FROM `cache` WHERE k='%s'",
+ dbesc($embedurl));
+ if(count($r)){
+ $txt = $r[0]['v'];
+ } else {
+ $ourl = "http://oohembed.com/oohembed/?url=".urlencode($embedurl);
+ $txt = fetch_url($ourl);
+ //save in cache
+ q("INSERT INTO `cache` VALUES ('%s','%s','%s')",
+ dbesc($embedurl),
+ dbesc($txt),
+ dbesc(datetime_convert()));
+ }
$j = json_decode($txt);
$ret="<span class='oembed'>";
switch ($j->type) {