From 96a41a16fd90492a9fca62fc675c9e09e0979a88 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Fri, 4 Apr 2014 10:56:33 +0200 Subject: [PATCH] oembed: Now it is possible to use the service from embedly with an API key. --- include/oembed.php | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/include/oembed.php b/include/oembed.php index ee042f8ce..17fc873cc 100755 --- a/include/oembed.php +++ b/include/oembed.php @@ -12,6 +12,9 @@ function oembed_replacecb($matches){ function oembed_fetch_url($embedurl){ + $embedurl = trim($embedurl, "'"); + $embedurl = trim($embedurl, '"'); + $a = get_app(); $txt = Cache::get($a->videowidth . $embedurl); @@ -48,9 +51,18 @@ function oembed_fetch_url($embedurl){ } if ($txt==false || $txt==""){ - // try oohembed service - $ourl = "http://oohembed.com/oohembed/?url=".urlencode($embedurl).'&maxwidth=' . $a->videowidth; - $txt = fetch_url($ourl); + $embedly = get_config("system", "embedly"); + if ($embedly == "") { + // try oohembed service + $ourl = "http://oohembed.com/oohembed/?url=".urlencode($embedurl).'&maxwidth=' . $a->videowidth; + $txt = fetch_url($ourl); + } else { + // try embedly service + $ourl = "https://api.embed.ly/1/oembed?key=".$embedly."&url=".urlencode($embedurl); + $txt = fetch_url($ourl); + } + + logger("oembed_fetch_url: ".$txt, LOGGER_DEBUG); } $txt=trim($txt);