aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Lib/Zotfinger.php
diff options
context:
space:
mode:
authorzotlabs <mike@macgirvin.com>2018-08-06 17:43:22 -0700
committerzotlabs <mike@macgirvin.com>2018-08-06 17:43:22 -0700
commit166879b8b04f8656a0ef105c319b8b4a82626bd9 (patch)
tree4244b1a57ab90d7588c57789c027beeffeb6ede2 /Zotlabs/Lib/Zotfinger.php
parentaeb9d5cd90a3bcb79c8d0b1645ece47e8756f422 (diff)
downloadvolse-hubzilla-166879b8b04f8656a0ef105c319b8b4a82626bd9.tar.gz
volse-hubzilla-166879b8b04f8656a0ef105c319b8b4a82626bd9.tar.bz2
volse-hubzilla-166879b8b04f8656a0ef105c319b8b4a82626bd9.zip
bring some Zot6 libraries and interfaces to red/hubzilla
Diffstat (limited to 'Zotlabs/Lib/Zotfinger.php')
-rw-r--r--Zotlabs/Lib/Zotfinger.php50
1 files changed, 50 insertions, 0 deletions
diff --git a/Zotlabs/Lib/Zotfinger.php b/Zotlabs/Lib/Zotfinger.php
new file mode 100644
index 000000000..537e440d4
--- /dev/null
+++ b/Zotlabs/Lib/Zotfinger.php
@@ -0,0 +1,50 @@
+<?php
+
+namespace Zotlabs\Lib;
+
+use Zotlabs\Web\HTTPSig;
+
+class Zotfinger {
+
+ static function exec($resource,$channel = null) {
+
+ if(! $resource) {
+ return false;
+ }
+
+ if($channel) {
+ $headers = [
+ 'Accept' => 'application/x-zot+json',
+ 'X-Zot-Token' => random_string(),
+ ];
+ $h = HTTPSig::create_sig($headers,$channel['channel_prvkey'],channel_url($channel),false);
+ }
+ else {
+ $h = [ 'Accept: application/x-zot+json' ];
+ }
+
+ $result = [];
+
+
+ $redirects = 0;
+ $x = z_fetch_url($resource,false,$redirects, [ 'headers' => $h ] );
+
+ if($x['success']) {
+
+ $result['signature'] = HTTPSig::verify($x);
+
+ $result['data'] = json_decode($x['body'],true);
+
+ if($result['data'] && is_array($result['data']) && array_key_exists('encrypted',$result['data']) && $result['data']['encrypted']) {
+ $result['data'] = json_decode(crypto_unencapsulate($result['data'],get_config('system','prvkey')),true);
+ }
+
+ return $result;
+ }
+
+ return false;
+ }
+
+
+
+} \ No newline at end of file