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
456 stars 166 forks source link

Unsupported post request. Object with ID 'xxxxxxxxxx' does not exist #42

Closed hacker-prime closed 1 year ago

hacker-prime commented 1 year ago

I am not sure how to solve this error. I just started using this repository today and I am very new to the WhatsApp API/Facebook Developer Ecosystem.

aalbarca commented 1 year ago

Hello,

We can't help you if you don't provide more information about your problem. What did you try to do? Which information did you try to send to the Cloud Api?

Thanks.

hacker-prime commented 1 year ago

I no longer get that error. I found the phone number ID on the following page: https://developers.facebook.com/apps/xxxxxxxxxx/whatsapp-business/wa-dev-console/?business_id=xxxxxxxx Afterwards, I tried to send a message using the following script:

<?php

// Require the Composer autoloader.
require 'vendor/autoload.php';

use Netflie\WhatsAppCloudApi\WhatsAppCloudApi;

// Instantiate the WhatsAppCloudApi super class.
$whatsapp_cloud_api = new WhatsAppCloudApi([
'from_phone_number_id' => 'xxxxxxxxx',// https://developers.facebook.com/apps/xxxxxxx/whatsapp-business/wa-dev-console/?business_id=xxxxxxx
'access_token' => 'xxxxxxxx', //How to get Permanent Access Token in WhatsApp Cloud API - https://www.youtube.com/watch?v=gqiBzFlF44c
]);

$whatsapp_cloud_api->sendTextMessage('+18764586888', 'Hey there! I\'m using WhatsApp Cloud API. Visit https://www.netflie.es');

?>

PLEASE NOTE- The from_phone_number_id and access_token values have been removed from the code snippet for security purposes.
When I run the code at the following url: http://localhost/whatsapp_api/ I don't get a message on my phone and the screen is blank.

aalbarca commented 1 year ago

WhatsApp Cloud Api doesn't allow start a conversation with a simple text message. You have to start a business-initied conversation sending a template: https://developers.facebook.com/docs/whatsapp/pricing/. Please, read and understand the Facebook Documentation before use this PHP client.

hacker-prime commented 1 year ago

I wasn't trying to send a template. According to WhatsAppCloudApi.php there are various functions one of which is SendTemplate() but I was using sendTextMessage().

hacker-prime commented 1 year ago

So after you send a template you will be able to start sending simple text messages?

oziomadot commented 9 months ago

Unsupported post request. Object with ID 'xxxxxxxxxxxxxxxxxx' does not exist, cannot be loaded due to missing permissions, or does not support this operation.

I still get this error. Please any solution or suggestion. I am sending a message templet but i get this error