From af010ddd55ef443d49f50db69dc34e6cb829441c Mon Sep 17 00:00:00 2001 From: "Namhyeon, Go" Date: Tue, 11 Jul 2023 15:27:28 +0900 Subject: [PATCH] Update activitypub.extend.php --- extend/activitypub.extend.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/extend/activitypub.extend.php b/extend/activitypub.extend.php index b4e9af4..01bb62e 100644 --- a/extend/activitypub.extend.php +++ b/extend/activitypub.extend.php @@ -370,6 +370,8 @@ function activitypub_http_get($url, $access_token = '') { "Date" => activitypub_build_date('now'), "Accept" => "application/ld+json; profile=\"" . NAMESPACE_ACTIVITYSTREAMS . "\"" ); + + // set access token if (!empty($access_token)) { $headers["Authorization"] = "Bearer " . $access_token; } @@ -416,15 +418,18 @@ function activitypub_http_post($url, $raw_data, $access_token = '', $mb = null) $headers = array( "Date" => $date, "Digest" => $digest, - "Accept" => "application/ld+json; profile=\"" . NAMESPACE_ACTIVITYSTREAMS . "\"", + "Content-Type" => "application/ld+json; profile=\"" . NAMESPACE_ACTIVITYSTREAMS . "\"", ); - if (!empty($access_token)) { - $headers["Authorization"] = "Bearer " . $access_token; - } list($private_key, $public_key) = activitypub_get_stored_keypair($mb); // build the signature $signature = activitypub_build_signature($url, $date, $digest, $private_key, $mb, "POST"); + $headers["Signature"] = $signature; + + // set access token + if (!empty($access_token)) { + $headers["Authorization"] = "Bearer " . $access_token; + } // request $ch = curl_init();