Open scammo opened 7 months ago
Hi @scammo Peertube Ontology has been fixed. Can you update to 0.7.2 and test again with this example : https://landrok.github.io/activitypub/fetch-peertube-outbox-activities-using-ontologies.html ?
Hey, thanks for your quick result. I'm still getting errors when using the linked code and following two handles: thunderbird_channel@tilvids.com, blender_channel@video.blender.org. The problem seems to be that $item->object is of type string. A link to the resource, not an object.
ActivityPhp\Type\Extended\Activity\Announce {#320 ▼ // app/Http/Controllers/ExampleController.php:53
-_props: array:6 [▼
"type" => "Announce"
"to" => array:1 [▶]
"cc" => array:1 [▶]
"id" => "https://tilvids.com/videos/watch/f895d15c-b97c-4c82-8661-c91e25dad078/announces/129600"
"actor" => "https://tilvids.com/video-channels/thunderbird_channel"
"object" => "https://tilvids.com/videos/watch/f895d15c-b97c-4c82-8661-c91e25dad078"
]
#id: null
#type: "Announce"
#attachment: null
#attributedTo: null
#audience: null
#content: null
#context: null
#contentMap: null
#name: null
#nameMap: null
#endTime: null
#generator: null
#icon: null
#image: null
#inReplyTo: null
#location: null
#preview: null
#published: null
#replies: null
#startTime: null
#summary: null
#summaryMap: null
#tag: null
#updated: null
#url: null
#to: null
#bto: null
#cc: null
#bcc: null
#mediaType: null
#duration: null
#source: null
#actor: null
#target: null
#result: null
#origin: null
#instrument: null
#object: null
}
There are 2 different things:
thunderbird_channel@tilvids.com
You're true, Announce->object is a string (url)
blender_channel@video.blender.org
This one is more Nginx-y. Gateway randomly fails. So you need to catch exception.
Here is a naive example of how to do that :
use ActivityPhp\Server;
use Exception;
/* ------------------------------------------------------------------
| Use an instance with a PeerTube flavor
------------------------------------------------------------------ */
// Create a server instance and allow peertube ontology
$server = new Server([
'ontologies' => [
'peertube',
]
]);
$handle = 'blender_channel@video.blender.org';
$handle = 'thunderbird_channel@tilvids.com';
// Get an actor's outbox as an OrderedCollection
$outbox = $server->outbox($handle);
// Prepare a stack
$pages = [];
// Browse first page
$page = $outbox->getPage($outbox->get()->first);
// Browse all pages and get public actvities
$pages[] = $page;
while ($page->next !== null) {
$page = readNextPage($outbox, $page);
$pages[] = $page;
}
echo "\n";
// Now we can work with pages
foreach ($pages as $page) {
foreach ($page->orderedItems as $item) {
echo sprintf(
"Type=%s, NameOrUrl=%s\n",
$item->type, // Activity type
is_object($item->object) //
? $item->object->name // Video name
: $item->object // Video Url
);
}
}
/**
* This function retry to read the failing page FOREVER
*/
function readNextPage($outbox, $page)
{
try {
return $outbox->getPage($page->next);
} catch(Exception $e) {
sleep(5);
}
return readNextPage($outbox, $page);
}
Please take into consideration that this is just an example which should neither be used as is in a production environment nor in a controller, whether with Laravel or another framework 😉
I've been trying to run https://landrok.github.io/activitypub/fetch-peertube-outbox-activities.html but I can't get a result from the various Peertube accounts. For example: blender@video.blender.org.
Could you check if the documentation is still correct? Could you maybe look at some sample profiles that work with the script?
The first issues their about undefined properties, but event after defining them I still ran into issues.
Thanks again for all your work and documentation!