netflie / whatsapp-cloud-api

The first PHP API to send and receive messages using a cloud-hosted version of the WhatsApp Business Platform
https://netflie.es/portfolio/whatsapp-business-cloud-api-php-sdk/
MIT License
428 stars 151 forks source link

Getting error "Unsupported post request. Object with ID '+919xxxxxxx' does not exist..." #160

Closed sh00nyan closed 6 months ago

sh00nyan commented 6 months ago

I am trying netflie/laravel-notification-whatsapp and getting following error when I access the URL http::localhost:8000/wa

Unsupported post request. Object with ID '+919xxxxxxx' does not exist, cannot be loaded due to missing permissions, or does not support this operation. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api

Unable to resolve the issue. Please help.

What I have done:

  1. create whatsapp channel in config/services.php
...
'whatsapp' => [
    'from-phone-number-id' => env('WHATSAPP_FROM_PHONE_NUMBER_ID'),
    'token' => env('WHATSAPP_TOKEN'),
],
  1. update .env
WHATSAPP_FROM_PHONE_NUMBER_ID='+919xxxxxxx'
WHATSAPP_TOKEN='tokenxxxxxxxx'
  1. create new notification class TestNotification
namespace App\Notifications;

use DateTimeImmutable;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use NotificationChannels\WhatsApp\Component;
use NotificationChannels\WhatsApp\WhatsAppChannel;
use NotificationChannels\WhatsApp\WhatsAppTemplate;

class TestNotification extends Notification
{
    use Queueable;

    /**
     * Get the notification's delivery channels.
     *
     * @return array
     */
    public function via(): array
    {
        return [WhatsAppChannel::class];
    }

    /**
     * Get the array representation of the notification.
     *
     * @return WhatsAppTemplate
     */
    public function toWhatsapp(): WhatsAppTemplate
    {
        return WhatsAppTemplate::create()
            ->name('app_notification')
            ->body(Component::dateTime(new DateTimeImmutable()))
            ->body(Component::text('Hi there.'))
            ->to('+91xxxxxxxxx');
    }
}
  1. add a route entry for testing (routes/web.php)
<?php

use Illuminate\Support\Facades\Notification;
use App\Notifications\TestNotification;

Notification::route('whatsapp', '/wa')->notify(new TestNotification());
aalbarca commented 6 months ago

Hi @sh00nyan

API errors should to to be resolved by Meta not here.

BTW https://developers.facebook.com/community/threads/312575526328116/?locale=es_LA

Best regards.