aboutsummaryrefslogtreecommitdiffstats
path: root/include/diaspora.php
diff options
context:
space:
mode:
authorFriendika <info@friendika.com>2011-09-18 20:17:44 -0700
committerFriendika <info@friendika.com>2011-09-18 20:17:44 -0700
commit48ee3fa3b9c540185fb3691ce6a971dd2cf1fd68 (patch)
tree14eeaaf7b0204e06e9636fbd1fc215fb0ec0c7b3 /include/diaspora.php
parent5b3f6459392ba6f417cfc5cb0d38094c009c6913 (diff)
downloadvolse-hubzilla-48ee3fa3b9c540185fb3691ce6a971dd2cf1fd68.tar.gz
volse-hubzilla-48ee3fa3b9c540185fb3691ce6a971dd2cf1fd68.tar.bz2
volse-hubzilla-48ee3fa3b9c540185fb3691ce6a971dd2cf1fd68.zip
build diaspora public (batch) message
Diffstat (limited to 'include/diaspora.php')
-rw-r--r--include/diaspora.php46
1 files changed, 46 insertions, 0 deletions
diff --git a/include/diaspora.php b/include/diaspora.php
index 313324a16..a6f3002b9 100644
--- a/include/diaspora.php
+++ b/include/diaspora.php
@@ -103,6 +103,52 @@ function get_diaspora_key($uri) {
}
+function diaspora_pubmsg_build($msg,$user,$contact,$prvkey,$pubkey) {
+ $a = get_app();
+
+ logger('diaspora_pubmsg_build: ' . $msg, LOGGER_DATA);
+
+
+ $handle = $user['nickname'] . '@' . substr($a->get_baseurl(), strpos($a->get_baseurl(),'://') + 3);
+
+ $b64_data = base64_encode($msg);
+ $b64url_data = base64url_encode($b64_data);
+
+ $data = str_replace(array("\n","\r"," ","\t"),array('','','',''),$b64url_data);
+
+ $type = 'application/xml';
+ $encoding = 'base64url';
+ $alg = 'RSA-SHA256';
+
+ $signable_data = $data . '.' . base64url_encode($type) . '.'
+ . base64url_encode($encoding) . '.' . base64url_encode($alg) ;
+
+ $signature = rsa_sign($signable_data,$prvkey);
+ $sig = base64url_encode($signature);
+
+$magic_env = <<< EOT
+<?xml version='1.0' encoding='UTF-8'?>
+<diaspora xmlns="https://joindiaspora.org/protocol" xmlns:me="http://salmon-protocol.org/ns/magic-env" >
+ <header>
+ <author_id>$handle</author_id>
+ </header>
+ <me:env>
+ <me:encoding>base64url</me:encoding>
+ <me:alg>RSA-SHA256</me:alg>
+ <me:data type="application/xml">$data</me:data>
+ <me:sig>$sig</me:sig>
+ </me:env>
+</diaspora>
+EOT;
+
+ logger('diaspora_pubmsg_build: magic_env: ' . $magic_env, LOGGER_DATA);
+ return $magic_env;
+
+}
+
+
+
+
function diaspora_msg_build($msg,$user,$contact,$prvkey,$pubkey) {
$a = get_app();