phoneNumberId}\n"; echo " šŸ”— API URL: {$config->getApiUrl()}\n\n"; // 2. Create HTTP client and WhatsApp client echo "2ļøāƒ£ Creating WhatsApp client...\n"; $httpClient = new CurlHttpClient(); $whatsappClient = new WhatsAppClient($httpClient, $config); echo " āœ… Client created\n\n"; // 3. Test phone number $testPhoneNumber = PhoneNumber::fromString('+4917941122213'); echo "3ļøāƒ£ Test recipient: {$testPhoneNumber->toDisplayFormat()}\n\n"; // 4. Send text message echo "4ļøāƒ£ Sending text message...\n"; try { $response = $whatsappClient->sendTextMessage( to: $testPhoneNumber, message: "šŸŽ‰ Test message from Custom PHP Framework!\n\nThis is a test notification via WhatsApp Business API." ); echo " āœ… Message sent successfully!\n"; echo " šŸ“Ø Message ID: {$response->messageId->toString()}\n\n"; } catch (\Throwable $e) { echo " āŒ Text message failed: {$e->getMessage()}\n\n"; } // 5. Send template message (hello_world template) echo "5ļøāƒ£ Sending template message...\n"; try { $templateResponse = $whatsappClient->sendTemplateMessage( to: $testPhoneNumber, templateId: WhatsAppTemplateId::fromString('hello_world'), languageCode: 'en_US' ); echo " āœ… Template message sent successfully!\n"; echo " šŸ“Ø Message ID: {$templateResponse->messageId->toString()}\n\n"; } catch (\Throwable $e) { echo " āŒ Template message failed: {$e->getMessage()}\n\n"; } // 6. Test with parameters (if you have a template with parameters) echo "6ļøāƒ£ Sending template with parameters...\n"; try { $paramResponse = $whatsappClient->sendTemplateMessage( to: $testPhoneNumber, templateId: WhatsAppTemplateId::fromString('sample_template'), // Replace with your template languageCode: 'en', parameters: ['John Doe', '2024-12-20'] ); echo " āœ… Parametrized template sent!\n"; echo " šŸ“Ø Message ID: {$paramResponse->messageId->toString()}\n\n"; } catch (\Throwable $e) { echo " ā„¹ļø Parametrized template skipped: {$e->getMessage()}\n\n"; } echo "āœ… WhatsApp notification test completed!\n\n"; echo "šŸ“ Notes:\n"; echo " - Replace test phone number with your WhatsApp number\n"; echo " - Phone number must be in E.164 format (+country code + number)\n"; echo " - Make sure the number is registered with your WhatsApp Business account\n"; echo " - Template names must be approved in your WhatsApp Business account\n"; } catch (\Throwable $e) { echo "\nāŒ Test failed: {$e->getMessage()}\n"; echo "Stack trace:\n{$e->getTraceAsString()}\n"; exit(1); }