]> git.mxchange.org Git - friendica.git/blobdiff - include/oembed.php
The CSS code for shared messages is moved from "vier" to the global.css, so that...
[friendica.git] / include / oembed.php
index ee042f8ce97a5869a9cd766d66d6580484102bbe..17fc873ccb304aa339cd4e24d5267a82a60e1015 100755 (executable)
@@ -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);