1. Go to this page and download the library: Download rmyndharis/openwa library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
rmyndharis / openwa example snippets
OpenWA\Client;
$client = new Client([
'baseUrl' => 'https://your-gateway.example.com',
'apiKey' => 'owa_k1_…',
]);
// Sessions are addressed by the UUID that create() returns, not by name. Create a session once;
// afterwards, find its id with $client->sessions->list(['name' => 'my-session']).
$session = $client->sessions->create(['name' => 'my-session']);
$client->sessions->start($session['id']);
// Link the account before sending: scan sessions->getQrCode or use sessions->requestPairingCode,
// then wait for status 'ready'. An unlinked session answers the send with 409.
$result = $client->messages->sendText($session['id'], [
'chatId' => '[email protected]',
'text' => 'Hello from the OpenWA PHP SDK!',
]);
echo $result['messageId'];