Update activitypub.extend.php
This commit is contained in:
parent
59a1248bf6
commit
76022bc3e1
|
@ -329,21 +329,21 @@ function activitypub_build_http_headers($headers) {
|
|||
return $lines;
|
||||
}
|
||||
|
||||
function activitypub_http_get($url, $access_token = '') {
|
||||
// make the time string
|
||||
function activitypub_build_date() {
|
||||
$tz = new DateTimeZone('GMT');
|
||||
$dt = new DateTime('now', $tz);
|
||||
$now = $dt->format('d M Y H:i:s e'); // e.g. 18 Dec 2019 10:08:46 GMT
|
||||
return $dt->format('d M Y H:i:s e'); // e.g. 18 Dec 2019 10:08:46 GMT
|
||||
}
|
||||
|
||||
function activitypub_http_get($url, $access_token = '') {
|
||||
// build the header
|
||||
$headers = array(
|
||||
"Date" => $now,
|
||||
"Date" => activitypub_build_date(),
|
||||
"Accept" => "application/ld+json; profile=\"" . NAMESPACE_ACTIVITYSTREAMS . "\""
|
||||
);
|
||||
if (!empty($access_token)) {
|
||||
$headers["Authorization"] = "Bearer " . $access_token;
|
||||
}
|
||||
// Todo: Add Signature header
|
||||
|
||||
// request
|
||||
$ch = curl_init();
|
||||
|
@ -380,15 +380,18 @@ function activitypub_get_attachments($bo_table, $wr_id) {
|
|||
|
||||
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(
|
||||
"Date" => activitypub_build_date(),
|
||||
"Accept" => "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);
|
||||
|
||||
// TODO: make Signature header
|
||||
// TODO: Add Signature header
|
||||
|
||||
// do HTTP request
|
||||
// request
|
||||
$ch = curl_init();
|
||||
curl_setopt_array($ch, array(
|
||||
CURLOPT_URL => $url,
|
||||
|
|
Loading…
Reference in New Issue
Block a user