Integration
PHP backend integration.
Use this general server-side example as the starting point for jobs, articles, products, listings, events, announcements, or custom content.
PHP
How this integration works
Use this in Laravel or a PHP backend service class.
Keep your zedgad API key on the server. The integration sends a title, summary, public URL, optional image URL, and any useful metadata to the project webhook.
- Place the service somewhere like app/Services/ZedgadService.php.
- Store ZEDGAD_API_KEY in your backend .env file.
- Call the service after the post, product, listing, or article becomes public.
PHP
Create app/Services/ZedgadService.php
Replace the sample content fields with your own model fields. The important part is that zedgad receives a stable ID, content type, title, summary, public URL, optional image URL, and any metadata you want to keep with the post.
app/Services/ZedgadService.php
<?php
namespace App\Services;
use Illuminate\Support\Facades\Http;
class ZedgadService
{
private string $webhookUrl = "https://api.zedgad.com/api/webhooks/content/";
public function sendContent($content): array
{
$response = Http::withToken(env('ZEDGAD_API_KEY'))
->timeout(20)
->post($this->webhookUrl, [
'external_id' => (string) $content->id,
'type' => $content->type ?? 'article',
'title' => $content->title,
'summary' => $content->summary,
'url' => $content->public_url,
'image_url' => $content->image_url,
'metadata' => [
'source' => $content->source ?? 'website',
'category' => $content->category,
],
]);
$response->throw();
return $response->json();
}
}