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