1. Go to this page and download the library: Download blacklinecloud/gowa-php-sdk 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/ */
blacklinecloud / gowa-php-sdk example snippets
use BlacklineCloud\SDK\GowaPHP\Client\AppClient;
use BlacklineCloud\SDK\GowaPHP\Client\SendClient;
use BlacklineCloud\SDK\GowaPHP\Config\ClientConfigBuilder;
use BlacklineCloud\SDK\GowaPHP\Http\ClientFactory;
use BlacklineCloud\SDK\GowaPHP\Support\NativeUuidGenerator;
use Nyholm\Psr7\Factory\Psr17Factory;
use Nyholm\Psr7\HttpClient\CurlClient;
use Psr\Log\NullLogger;
$config = ClientConfigBuilder::fromArray([
'base_uri' => 'http://localhost:3000',
'username' => 'admin',
'password' => 'admin',
]);
$factory = new ClientFactory(
requestFactory: $psr17 = new Psr17Factory(),
streamFactory: $psr17,
psr18: new CurlClient($psr17),
logger: new NullLogger(),
uuid: new NativeUuidGenerator(),
);
$app = $factory->createAppClient($config);
$send = $factory->createSendClient($config);
// Login (QR)
$app->login();
// Send text
$send->text('[email protected]', 'Hello from PHP');
// Send chat presence
$send->chatPresence('[email protected]', \BlacklineCloud\SDK\GowaPHP\Domain\Enum\PresenceState::Composing);
$raw = file_get_contents('php://input');
$sig = $_SERVER['HTTP_X_HUB_SIGNATURE_256'] ?? '';
$verifier = new \BlacklineCloud\SDK\GowaPHP\Webhook\WebhookVerifier('your-secret');
if (! $verifier->verify($raw, $sig)) {
http_response_code(401);
exit('invalid signature');
}
$event = (new \BlacklineCloud\SDK\GowaPHP\Webhook\WebhookEventHydrator())->hydrate(\BlacklineCloud\SDK\GowaPHP\Serialization\Json::decode($raw));
bash
composer
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.