3 namespace Friendica\Object;
8 * @see https://oembed.com/#section2.3
10 * @author Hypolite Petovan <hypolite@mrpetovan.com>
14 public $embed_url = '';
18 public $author_name = '';
19 public $author_url = '';
20 public $provider_name = '';
21 public $provider_url = '';
22 public $cache_age = '';
23 public $thumbnail_url = '';
24 public $thumbnail_width = '';
25 public $thumbnail_height = '';
31 public function __construct($embed_url)
33 $this->embed_url = $embed_url;
36 public function parseJSON($json_string)
38 $properties = json_decode($json_string, true);
40 if (empty($properties)) {
44 foreach ($properties as $key => $value) {
45 if (in_array($key, ['thumbnail_width', 'thumbnail_height', 'width', 'height'])) {
46 // These values should be numbers, so ensure that they really are numbers.
48 } elseif (is_array($value)) {
50 } elseif ($key != 'html') {
51 // Avoid being able to inject some ugly stuff through these fields.
52 $value = htmlentities($value);
54 /// @todo Add a way to sanitize the html as well, possibly with an <iframe>?
55 $value = mb_convert_encoding($value, 'HTML-ENTITIES', mb_detect_encoding($value));
58 if (property_exists(__CLASS__, $key)) {
59 $this->{$key} = $value;