aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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) {