-
Notifications
You must be signed in to change notification settings - Fork 0
/
oembed.php
38 lines (31 loc) · 863 Bytes
/
oembed.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
$dir = __DIR__;
require ($dir . '/src/XF.php');
XF::start($dir);
$app = XF::setupApp('XF\Pub\App', [
'preLoad' => ['bbCodeMedia']
]);
/** @var \XF\Oembed\Controller $oEmbedFetcher */
$oEmbedFetcher = $app->oembed()->controller();
$request = $app->request();
$input = $request->filter([
'provider' => 'str',
'id' => 'str',
]);
$showDebugOutput = (\XF::$debugMode && $request->get('_debug'));
if (!empty($input['provider']) && !empty($input['id']))
{
$input['id'] = str_replace('{{_hash_}}', '#', $input['id']);
$response = $oEmbedFetcher->outputJson($input['provider'], $input['id']);
if ($showDebugOutput)
{
$response->contentType('text/html', 'utf-8');
$response->body($app->debugger()->getDebugPageHtml($app));
}
$response->send($request);
}
else
{
header('Content-type: text/plain; charset=utf-8', true, 400);
echo "Unknown type";
}