🚀 New: Anjok Connect WhatsApp Business App — Get Demo ₹500/mo

🚀 WhatsApp Cloud API Setup (Step-by-Step) – PHP + Webhook

In this blog, we explain WhatsApp Cloud API setup step by step, including:

  • Meta setup
  • Phone number configuration
  • Webhook setup
  • PHP code example
  • Common mistakes to avoid

https://cdn.botpenguin.com/assets/website/Whats_App_Cloud_API_3d24ae6184.webp

https://miro.medium.com/v2/da%3Atrue/resize%3Afit%3A1200/0%2AbQehiUjcZ2ohV3XM

https://www.qiscus.com/wp-content/uploads/2022/06/image-3-1024x502.png

💡 What is WhatsApp Cloud API?

WhatsApp Cloud API is an official API provided by Meta Platforms that allows businesses to:

  • Send WhatsApp messages programmatically
  • Receive messages via webhook
  • Build chatbots
  • Automate notifications
  • Integrate with PHP, CRM, ERP, Billing, HRM

No third-party gateway required.

✅ Requirements Before Setup

Before starting, make sure you have:

  • Facebook / Meta account
  • Business Manager access
  • PHP hosting (with HTTPS)
  • Domain or server (cPanel / VPS)
  • Basic PHP knowledge

🧩 STEP 1: Create Meta App & Enable WhatsApp

  1. Go to developers.facebook.com
  2. Click Create App
  3. Choose Business app type
  4. Add WhatsApp product
  5. Select Cloud API

Meta will auto-create:

  • WhatsApp Business Account (WABA)
  • Test phone number (⚠️ only for testing)

👉 Do NOT use test number for production

📱 STEP 2: Add Real Phone Number (Very Important)

Many people make mistake here.

❌ Wrong

  • Using test phone number only

✅ Correct

  1. Go to business.facebook.com
  2. Business Settings → WhatsApp Accounts
  3. Open your WhatsApp account
  4. Add real phone number
  5. Verify OTP
  6. Assign number to Cloud API

This step is mandatory for live messaging.

https://mobiletrans.wondershare.com/images/article/add-whatsapp-business-number-3.jpg

https://d33v4339jhl8k0.cloudfront.net/docs/assets/589c78fadd8c8e73b3e9710e/images/681645e956318b21e2f41544/file-FCLb6KAfsj.png

 

💳 STEP 3: Add Billing Method (Avoid Error 131042)

WhatsApp Cloud API requires billing eligibility.

  1. Business Settings → Payments
  2. Add debit/credit card or UPI
  3. Save & activate

Without this, messages will fail with:
Billing Eligibility Error – 131042

🔐 STEP 4: Get Access Token & Phone Number ID

From Meta Developer Dashboard:

  • Copy Permanent Access Token
  • Copy Phone Number ID
  • Copy WhatsApp Business Account ID

These are required in PHP code.

🌐 STEP 5: Setup Webhook URL (PHP)

Webhook is used to receive incoming WhatsApp messages.

Example Webhook URL:

 

https://yourdomain.com/whatsapp_webhook.php 

Webhook Verification (PHP)

 

<?php $verify_token = "anjok_verify_token"; if ($_GET['hub_verify_token'] === $verify_token) {    echo $_GET['hub_challenge']; } ?> 

Add this URL in:
Meta Dashboard → WhatsApp → Configuration → Webhooks

📩 STEP 6: Receive WhatsApp Messages (PHP Webhook)

 

<?php $input = file_get_contents("php://input"); file_put_contents("log.txt", $input, FILE_APPEND); $data = json_decode($input, true); $message = $data['entry'][0]['changes'][0]['value']['messages'][0]['text']['body'] ?? ''; $from = $data['entry'][0]['changes'][0]['value']['messages'][0]['from'] ?? ''; if ($message) {    // process message here } ?> 

Now your PHP app can receive WhatsApp messages.

📤 STEP 7: Send WhatsApp Message Using PHP

 

$token = "YOUR_ACCESS_TOKEN"; $phone_id = "YOUR_PHONE_NUMBER_ID"; $data = [  "messaging_product" => "whatsapp",  "to" => "91XXXXXXXXXX",  "text" => ["body" => "Hello from Anjok Technologies"] ]; $ch = curl_init("https://graph.facebook.com/v18.0/$phone_id/messages"); curl_setopt($ch, CURLOPT_HTTPHEADER, [  "Authorization: Bearer $token",  "Content-Type: application/json" ]); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data)); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); curl_close($ch);

Message sent successfully 🎉

🧠 STEP 8: Templates for Business Messages

For:

  • Offers
  • Notifications
  • Reminders

You must:

  • Create message templates
  • Get Meta approval
  • Then use them in API

We help with template approval also.

⚠️ Common Mistakes to Avoid

❌ Using test number in production
❌ Not adding payment method
❌ Webhook not HTTPS
❌ Token expired
❌ Wrong phone number ID

90% WhatsApp API issues come from setup mistakes.

🏢 How Anjok Technologies Helps

At Anjok Technologies, we provide:

✔ WhatsApp Cloud API full setup
✔ PHP webhook development
✔ Chatbot creation
✔ Bulk messaging system
✔ CRM / ERP / Billing integration
✔ Billing & error fixing (131042, webhook issues)
✔ Tamil + English chatbot support

We don’t just explain — we implement.

📞 Contact Anjok Technologies

📱 +91 80729 70517
🌐 anjoktechnologies.in

👉 Ask for WhatsApp Cloud API Demo (PHP)