diff options
author | Mario <mario@mariovavti.com> | 2017-10-25 13:29:19 +0200 |
---|---|---|
committer | Mario <mario@mariovavti.com> | 2017-10-25 13:29:19 +0200 |
commit | 344aa13c64f0fa7a246f3284bf9cdb267e6101d3 (patch) | |
tree | 943809c01164dda7b6e4a26bc3d6c7e8c48bd6eb /Zotlabs/Lib/ActivityStreams2.php | |
parent | 61c86212b944efa0d78dcc0364b81bfb8a0d19bc (diff) | |
parent | 69b22e3f7916b5ba19b5ed03a55ad72bf5995291 (diff) | |
download | volse-hubzilla-344aa13c64f0fa7a246f3284bf9cdb267e6101d3.tar.gz volse-hubzilla-344aa13c64f0fa7a246f3284bf9cdb267e6101d3.tar.bz2 volse-hubzilla-344aa13c64f0fa7a246f3284bf9cdb267e6101d3.zip |
Merge branch '2.8RC'
Diffstat (limited to 'Zotlabs/Lib/ActivityStreams2.php')
-rw-r--r-- | Zotlabs/Lib/ActivityStreams2.php | 86 |
1 files changed, 0 insertions, 86 deletions
diff --git a/Zotlabs/Lib/ActivityStreams2.php b/Zotlabs/Lib/ActivityStreams2.php deleted file mode 100644 index 904782bf7..000000000 --- a/Zotlabs/Lib/ActivityStreams2.php +++ /dev/null @@ -1,86 +0,0 @@ -<?php - -namespace Zotlabs\Lib; - - -class ActivityStreams2 { - - public $data; - public $valid = false; - public $id = ''; - public $type = ''; - public $actor = null; - public $obj = null; - public $tgt = null; - - function __construct($string) { - - $this->data = json_decode($string,true); - if($this->data) { - $this->valid = true; - } - - if($this->is_valid()) { - $this->id = $this->get_property_obj('id'); - $this->type = $this->get_primary_type(); - $this->actor = $this->get_compound_property('actor'); - $this->obj = $this->get_compound_property('object'); - $this->tgt = $this->get_compound_property('target'); - } - } - - function is_valid() { - return $this->valid; - } - - function get_property_obj($property,$base = '') { - if(! $base) { - $base = $this->data; - } - return $base[$property]; - } - - function fetch_property($url) { - $redirects = 0; - $x = z_fetch_url($url,true,$redirects, - ['headers' => [ 'Accept: application/ld+json; profile="https://www.w3.org/ns/activitystreams"']]); - if($x['success']) - return json_decode($x['body'],true); - return null; - } - - function get_compound_property($property,$base = '') { - $x = $this->get_property_obj($property,$base); - if($this->is_url($x)) { - $x = $this->fetch_property($x); - } - return $x; - } - - function is_url($url) { - if(($url) && (! is_array($url)) && (strpos($url,'http') === 0)) { - return true; - } - return false; - } - - function get_primary_type($base = '') { - if(! $base) - $base = $this->data; - $x = $this->get_property_obj('type',$base); - if(is_array($x)) { - foreach($x as $y) { - if(strpos($y,':') === false) { - return $y; - } - } - } - return $x; - } - - function debug() { - $x = var_export($this,true); - return $x; - } - -}
\ No newline at end of file |