You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
561B

  1. <?php
  2. use Graby\Graby;
  3. use Fusonic\OpenGraph\Consumer;
  4. /**
  5. * Graby.
  6. *
  7. * @param string $url
  8. * @return array
  9. */
  10. function graby(string $url) : array
  11. {
  12. $graby = new Graby();
  13. $result = $graby->fetchContent($url);
  14. if (isset($result['headers'])) {
  15. unset($result['headers']);
  16. }
  17. return $result;
  18. }
  19. /**
  20. * Opengraph
  21. *
  22. * @param string $url
  23. *
  24. * @return array
  25. */
  26. function opengraph(string $url) : array
  27. {
  28. $consumer = new Consumer();
  29. $object = $consumer->loadUrl($url);
  30. return json_decode(json_encode($object), true);
  31. }