request( 'POST', 'https://brid.gy/publish/webmention', [ 'headers' => [ 'Accept' => 'application/json', ], 'form_params' => [ 'source' => $this->note->uri, 'target' => 'https://brid.gy/publish/mastodon', ], 'http_errors' => false, ] ); $body = json_decode((string) $response->getBody(), true); if ($response->getStatusCode() === 201) { $this->note->mastodon_url = $body['url']; $this->note->save(); return; } throw new \RuntimeException( 'Bridgy publish to Mastodon failed: '.($body['error'] ?? (string) $response->getBody()) ); } }