cache oembed request
This commit is contained in:
parent
3dbca2a804
commit
bdbbfe17b0
1 changed files with 14 additions and 2 deletions
|
@ -1,8 +1,20 @@
|
|||
<?php
|
||||
function oembed_replacecb($matches){
|
||||
$embedurl=$matches[1];
|
||||
|
||||
$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) {
|
||||
|
|
Loading…
Reference in a new issue