Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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 #184

Closed
siyaadguul opened this issue Dec 21, 2021 · 18 comments
Labels

Comments

@siyaadguul
Copy link

when i tried to send Whatsapp message from my php

@CoolGoose CoolGoose added the bug label Dec 21, 2021
@CoolGoose
Copy link
Contributor

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

@siyaadguul
Copy link
Author

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()); } ?>

@siyaadguul
Copy link
Author

i am trying like this
and i want to send message to my customer usign php

@CoolGoose
Copy link
Contributor

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());
}

@siyaadguul
Copy link
Author

siyaadguul commented Dec 22, 2021

  • thank you sir

@siyaadguul
Copy link
Author

it's now working.
But the message get failed to send

@CoolGoose
Copy link
Contributor

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.

@siyaadguul
Copy link
Author

when i try to initiate new conversation i am gets error(MessageBird\Exceptions\AuthenticateException: Got error response from the server: Recipient not authorised)

@CoolGoose
Copy link
Contributor

@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.

@siyaadguul
Copy link
Author

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());
}

@siyaadguul
Copy link
Author

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

@CoolGoose
Copy link
Contributor

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();
}

@siyaadguul
Copy link
Author

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

@siyaadguul
Copy link
Author

I want customers whether I have spoken to them on whatsapp or not to get the message across

@CoolGoose
Copy link
Contributor

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

@siyaadguul
Copy link
Author

okey

@siyaadguul
Copy link
Author

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,

@dennisvdvliet
Copy link
Contributor

Closing this to due to inactivity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants