2020-04-27 05:43:54 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Services;
|
|
|
|
|
2021-09-20 06:21:16 +00:00
|
|
|
use Illuminate\Support\Facades\Http;
|
2020-04-27 05:43:54 +00:00
|
|
|
use App\Profile;
|
|
|
|
use App\Util\ActivityPub\Helpers;
|
|
|
|
use App\Util\ActivityPub\HttpSignature;
|
|
|
|
|
|
|
|
class ActivityPubFetchService
|
|
|
|
{
|
2021-01-17 19:51:07 +00:00
|
|
|
public static function get($url)
|
2020-04-27 05:43:54 +00:00
|
|
|
{
|
2021-01-26 04:44:07 +00:00
|
|
|
if(!Helpers::validateUrl($url)) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2021-09-20 06:21:16 +00:00
|
|
|
$headers = HttpSignature::instanceActorSign($url, false);
|
|
|
|
$headers['Accept'] = 'application/activity+json, application/json';
|
|
|
|
$headers['User-Agent'] = '(Pixelfed/'.config('pixelfed.version').'; +'.config('app.url').')';
|
2021-01-17 19:51:07 +00:00
|
|
|
|
2021-09-20 06:21:16 +00:00
|
|
|
return Http::withHeaders($headers)
|
2021-01-17 19:51:07 +00:00
|
|
|
->timeout(30)
|
|
|
|
->get($url)
|
|
|
|
->body();
|
2020-04-27 05:43:54 +00:00
|
|
|
}
|
2021-09-20 06:21:16 +00:00
|
|
|
}
|