Update activitypub.extend.php
This commit is contained in:
parent
58fb822d6f
commit
637bf4d95b
|
@ -90,6 +90,19 @@ function activitypub_create_keypair() {
|
||||||
return $keypair;
|
return $keypair;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function activitypub_get_stored_keypair($mb) {
|
||||||
|
$private_key = '';
|
||||||
|
$public_key = '';
|
||||||
|
|
||||||
|
if ($mb != null && !empty($mb['mb_id'])) {
|
||||||
|
$certificate_data = activitypub_parse_stored_data($mb[ACTIVITYPUB_CERTIFICATE_DATAFIELD]); // 인증서 정보 불러오기
|
||||||
|
$private_key = activitypub_get_memo($certificate_data['PrivateKeyId']); // 개인키(Private Key)
|
||||||
|
$public_key = activitypub_get_memo($certificate_data['PublicKeyId']); // 공개키(Public Key)
|
||||||
|
}
|
||||||
|
|
||||||
|
return array($private_key, $public_key);
|
||||||
|
}
|
||||||
|
|
||||||
function activitypub_get_library_data($name) {
|
function activitypub_get_library_data($name) {
|
||||||
global $activitypub_loaded_libraries;
|
global $activitypub_loaded_libraries;
|
||||||
|
|
||||||
|
@ -278,11 +291,13 @@ function activitypub_build_http_headers($headers) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function activitypub_http_get($url, $access_token = '') {
|
function activitypub_http_get($url, $access_token = '') {
|
||||||
|
// make HTTP header
|
||||||
$headers = array("Accept" => "application/ld+json; profile=\"" . NAMESPACE_ACTIVITYSTREAMS . "\"");
|
$headers = array("Accept" => "application/ld+json; profile=\"" . NAMESPACE_ACTIVITYSTREAMS . "\"");
|
||||||
if (!empty($access_token)) {
|
if (!empty($access_token)) {
|
||||||
$headers["Authorization"] = "Bearer " . $access_token;
|
$headers["Authorization"] = "Bearer " . $access_token;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// do HTTP request
|
||||||
$ch = curl_init();
|
$ch = curl_init();
|
||||||
curl_setopt_array($ch, array(
|
curl_setopt_array($ch, array(
|
||||||
CURLOPT_URL => $url,
|
CURLOPT_URL => $url,
|
||||||
|
@ -315,12 +330,17 @@ function activitypub_get_attachments($bo_table, $wr_id) {
|
||||||
return $attachments;
|
return $attachments;
|
||||||
}
|
}
|
||||||
|
|
||||||
function activitypub_http_post($url, $rawdata, $access_token = '') {
|
function activitypub_http_post($url, $raw_data, $access_token = '', $mb = null) {
|
||||||
|
// make HTTP header
|
||||||
$headers = array("Accept" => "application/ld+json; profile=\"" . NAMESPACE_ACTIVITYSTREAMS . "\"");
|
$headers = array("Accept" => "application/ld+json; profile=\"" . NAMESPACE_ACTIVITYSTREAMS . "\"");
|
||||||
if (!empty($access_token)) {
|
if (!empty($access_token)) {
|
||||||
$headers["Authorization"] = "Bearer " . $access_token;
|
$headers["Authorization"] = "Bearer " . $access_token;
|
||||||
}
|
}
|
||||||
|
list($private_key, $public_key) = activitypub_get_stored_keypair($mb);
|
||||||
|
|
||||||
|
// TODO: make Signature header
|
||||||
|
|
||||||
|
// do HTTP request
|
||||||
$ch = curl_init();
|
$ch = curl_init();
|
||||||
curl_setopt_array($ch, array(
|
curl_setopt_array($ch, array(
|
||||||
CURLOPT_URL => $url,
|
CURLOPT_URL => $url,
|
||||||
|
@ -328,7 +348,7 @@ function activitypub_http_post($url, $rawdata, $access_token = '') {
|
||||||
CURLOPT_SSL_VERIFYPEER => false,
|
CURLOPT_SSL_VERIFYPEER => false,
|
||||||
CURLOPT_CONNECTTIMEOUT => 10,
|
CURLOPT_CONNECTTIMEOUT => 10,
|
||||||
CURLOPT_RETURNTRANSFER => true,
|
CURLOPT_RETURNTRANSFER => true,
|
||||||
CURLOPT_POSTFIELDS => $rawdata,
|
CURLOPT_POSTFIELDS => $raw_data,
|
||||||
CURLOPT_POST => true
|
CURLOPT_POST => true
|
||||||
));
|
));
|
||||||
$response = curl_exec($ch);
|
$response = curl_exec($ch);
|
||||||
|
@ -977,9 +997,7 @@ class _GNUBOARD_ActivityPub {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 인증서 정보 불러오기
|
// 인증서 정보 불러오기
|
||||||
$certificate_data = activitypub_parse_stored_data($mb[ACTIVITYPUB_CERTIFICATE_DATAFIELD]);
|
list($private_key, $public_key) = activitypub_get_stored_keypair($mb);
|
||||||
$private_key = activitypub_get_memo($certificate_data['PrivateKeyId']); // 개인키(Private Key)
|
|
||||||
$public_key = activitypub_get_memo($certificate_data['PublicKeyId']); // 공개키(Public Key)
|
|
||||||
|
|
||||||
// 본문 생성
|
// 본문 생성
|
||||||
$activitypub_user_id = activitypub_get_url("user", array("mb_id" => $mb['mb_id']));
|
$activitypub_user_id = activitypub_get_url("user", array("mb_id" => $mb['mb_id']));
|
||||||
|
|
Loading…
Reference in New Issue
Block a user