3 namespace Friendica\Module;
5 use Friendica\BaseModule;
11 * Displays stored embed content based on a base64 hash of a remote URL
13 * Example: /oembed/aHR0cHM6Ly9...
15 * @author Hypolite Petovan <mrpetovan@gmail.com>
17 class Oembed extends BaseModule
19 public static function content()
23 // Unused form: /oembed/b2h?url=...
24 if ($a->argv[1] == 'b2h') {
25 $url = ["", trim(hex2bin($_REQUEST['url']))];
26 echo Content\OEmbed::replaceCallback($url);
30 // Unused form: /oembed/h2b?text=...
31 if ($a->argv[1] == 'h2b') {
32 $text = trim(hex2bin($_REQUEST['text']));
33 echo Content\OEmbed::HTML2BBCode($text);
39 $url = base64url_decode($a->argv[1]);
40 $j = Content\OEmbed::fetchURL($url);
42 // workaround for media.ccc.de (and any other endpoint that return size 0)
43 if (substr($j->html, 0, 7) == "<iframe" && strstr($j->html, 'width="0"')) {
44 $j->html = '<style>html,body{margin:0;padding:0;} iframe{width:100%;height:100%;}</style>' . $j->html;
45 $j->html = str_replace('width="0"', '', $j->html);
46 $j->html = str_replace('height="0"', '', $j->html);
49 echo '</body></html>';