PHP code example of scriptdevelop / meta-catalog-manager
1. Go to this page and download the library: Download scriptdevelop/meta-catalog-manager library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
scriptdevelop / meta-catalog-manager example snippets
use ScriptDevelop\MetaCatalogManager\Facades\MetaCatalog;
// With context account
MetaCatalog::forAccount($account)->catalog()->syncFromApi();
// Direct access
MetaCatalog::account()->create([...]);
MetaCatalog::catalog()->syncFromApi($account);
// Manual flow (auto-fetches name + syncs catalogs)
$account = MetaCatalog::account()->create([
'meta_business_id' => '123456789',
'access_token' => 'EAABwz...',
]);
// Get the auto-fetched business name
echo $account->name; // "My Business Name" (from Meta API)
// Embedded Signup flow (WhatsApp OAuth)
$account = MetaCatalog::account()->createFromEmbeddedSignup([
'business_id' => '2729063490586005',
'code' => 'AQBhlXsctMxJYb...',
]);
// Find / list
$account = MetaCatalog::account()->find($ulid);
$account = MetaCatalog::account()->findByMetaBusinessId('123456789');
$accounts = MetaCatalog::account()->all();
// Sync catalogs from Meta API to local DB
$catalogs = MetaCatalog::catalog()->syncFromApi($account);
// Create a catalog
$catalog = MetaCatalog::catalog()->create($account, [
'name' => 'My Store Catalog',
'vertical' => 'commerce',
]);
// Create a Page-Owned catalog
$catalog = MetaCatalog::catalog()->createForPage($account, $pageId, [
'name' => 'Page Catalog',
]);
// Implement your own processor
class MyWebhookProcessor implements \ScriptDevelop\MetaCatalogManager\Contracts\WebhookProcessorInterface
{
public function handle(Request $request): Response|JsonResponse { ... }
public function verifyWebhook(Request $request, string $verifyToken): Response { ... }
public function processProductFeed(array $payload): void { ... }
public function processItemsBatch(array $payload): void { ... }
}
// Set in .env
META_CATALOG_WEBHOOK_PROCESSOR=\\App\\Webhooks\\MyWebhookProcessor
META_CATALOG_WEBHOOK_VERIFY_TOKEN=your_secret_token