Fatal error: Uncaught Error: Class "MessageBirdObjectsConversationContent" not found in F:\xampp\htdocs\habraacdb\api\index.php:7 Stack trace: #0 {main} thrown in F:\xampp\htdocs\habraacdb\api\index.php on line 7
when i tried to send Whatsapp message from my php
Hi @siyaadguul .
Can you please provide some details and maybe a short code sample on how you're trying to do the call ? From the error stack above it looks more like an issue loading the class rather than an implementation issue.
Thanks
text = 'Hello!'; $message = new MessageBirdObjectsConversationMessage(); $message->content = $content; $message->to = '252615302173'; $message->type = 'text'; $message->channelId = 'chan_id'; try { $conversation = $MessageBird->conversations->start($message); var_dump($conversation); } catch (Exception $e) { echo sprintf("%s: %s", get_class($e), $e->getMessage()); } ?>
i am trying like this and i want to send message to my customer usign php
Hey, you can check the examples folder for some code sample, but for starting a conversation it should be like: We do use namespaces for the class.
$messageBird = new \MessageBird\Client('YOUR_ACCESS_KEY'); // Set your own API access key here.
$content = new \MessageBird\Objects\Conversation\Content();
$content->text = 'Hello world';
$message = new \MessageBird\Objects\Conversation\Message();
$message->channelId = 'CHANNEL_ID';
$message->content = $content;
$message->to = 'RECIPIENT'; // Channel-specific, e.g. MSISDN for SMS.
$message->type = 'text';
try {
$conversation = $messageBird->conversations->start($message);
var_dump($conversation);
} catch (\Exception $e) {
echo sprintf("%s: %s", get_class($e), $e->getMessage());
}
- [ ] thank you sir
it's now working. But the message get failed to send
If the SDK call didn't error out, it should get into MessageBird's system so I would recommend contacting MessageBird's support with details about channelId/ recipient so we don't expose sensitive information on public boards.
when i try to initiate new conversation i am gets error(MessageBird\Exceptions\AuthenticateException: Got error response from the server: Recipient not authorised)
@siyaadguul that is the authentication error in case you didn't send the correct YOUR_ACCESS_KEY. For that purpose, I would also advise contacting MessageBird internally so we don't leak information.
Okey Thank you i fixed it but the only condition that i am facing now is when i execute and send a message it gets done but when i tried to send with another contact it get undone and no messages reaches to the target example of my code require('autoload.php');
// Set your own API access key here. // Create a client with WhatsApp sandbox enabled. $messageBird = new \MessageBird\Client('key');
// Use WhatsApp sandbox channel as normal.
$content = new \MessageBird\Objects\Conversation\Content(); $content->text = 'Hello world';
$message = new \MessageBird\Objects\Conversation\SendMessage(); $message->from = 'chid'; $message->content = $content; $message->to = '252616429555'; // Channel-specific, e.g. MSISDN for SMS. $message->type = 'text';
try { $conversation = $messageBird->conversationSend->send($message);
var_dump($conversation);
} catch (Exception $e) { echo sprintf("%s: %s", get_class($e), $e->getMessage()); }
i want to send a message to my every customer who reaches my website or did registred in my system example so send updates,notices,offers,bills and so on
If you don't need 2 way communication and you just want to notify your customers I'd recommend using the simpler send message functionality.
When you say you want to send from another contact, are you doing a for/foreach for multiple contacts, or are you just calling this same endpoint a couple of times?
$messageBird = new \MessageBird\Client('YOUR_ACCESS_KEY'); // Set your own API access key here.
$message = new \MessageBird\Objects\Message();
$message->originator = 'YourBrand';
$message->recipients = [31612345678];
$message->body = 'This is a test message.';
try {
$messageResult = $messageBird->messages->create($message);
var_dump($messageResult);
} catch (\MessageBird\Exceptions\AuthenticateException $e) {
// That means that your accessKey is unknown
echo 'wrong login';
} catch (\MessageBird\Exceptions\BalanceException $e) {
// That means that you are out of credits, so do something about it.
echo 'no balance';
} catch (\Exception $e) {
echo $e->getMessage();
}
i want to send whatsapp messages to my customers not messages first. and i think this code is about sms second i want to call if contact is about 1 contact if its more than one contact or customer i have to use looping like for or while
I want customers whether I have spoken to them on whatsapp or not to get the message across
Understood. I'll do a test run locally also and get back to you. There's no reason why another call shouldn't work for you. Thanks
okey
Understood. I'll do a test run locally also and get back to you. There's no reason why another call shouldn't work for you. Thanks
hi Sir,
Closing this to due to inactivity.