em.php 1011 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. /**
  3. * Copyright (c) UNA, Inc - https://una.io
  4. * MIT License - https://opensource.org/licenses/MIT
  5. *
  6. * @defgroup UnaCore UNA Core
  7. * @{
  8. */
  9. require_once('./inc/header.inc.php');
  10. $aEmbedData = BxDolPage::getEmbedData(bx_get('url'));
  11. if(empty($aEmbedData)){
  12. header('HTTP/1.0 404 Not Found');
  13. header('Status: 404 Not Found');
  14. exit();
  15. }
  16. $aResult = [
  17. 'version' => '1.0',
  18. 'type' => 'rich',
  19. 'title' => $aEmbedData['title'],
  20. 'url' => $aEmbedData['url'],
  21. 'provider_name' => getParam('site_title'),
  22. 'provider_url' => BX_DOL_URL_ROOT,
  23. 'html' => $aEmbedData['html'],
  24. ];
  25. if ($aEmbedData['thumbnail_url']){
  26. $aResult['thumbnail_url'] = $aEmbedData['thumbnail_url'];
  27. }
  28. if ($aEmbedData['author_name']){
  29. $aResult['author_name'] = $aEmbedData['author_name'];
  30. }
  31. if ($aEmbedData['author_url']){
  32. $aResult['author_url'] = $aEmbedData['author_url'];
  33. }
  34. header('Content-Type: application/json; charset=utf-8');
  35. echo json_encode($aResult);