Burn notices, burn
[friendica.git/.git] / src / Object / OEmbed.php
1 <?php
2
3 namespace Friendica\Object;
4
5 /**
6  * OEmbed data object
7  *
8  * @see https://oembed.com/#section2.3
9  *
10  * @author Hypolite Petovan <mrpetovan@gmail.com>
11  */
12 class OEmbed
13 {
14         public $embed_url        = '';
15
16         public $type             = '';
17         public $title            = '';
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 = '';
26         public $html             = '';
27         public $url              = '';
28         public $width            = '';
29         public $height           = '';
30
31         public function __construct($embed_url)
32         {
33                 $this->embed_url = $embed_url;
34         }
35
36         public function parseJSON($json_string)
37         {
38                 $properties = json_decode($json_string, true);
39
40                 if (empty($properties)) {
41                         return;
42                 }
43
44                 foreach ($properties as $key => $value) {
45                         if (property_exists(__CLASS__, $key)) {
46                                 $this->{$key} = $value;
47                         }
48                 }
49         }
50 }