samples/testSendE2EText.php
<?php
use Threema\MsgApi\Connection;
use Threema\MsgApi\ConnectionSettings;
//include_project
require_once 'bootstrap.php';
//define your connection settings
$settings = new ConnectionSettings(
'*YOUR_GATEWAY_THREEMA_ID',
'YOUR_GATEWAY_THREEMA_ID_SECRET'
);
//public key store file
//best practice: create a publickeystore
//$publicKeyStore = new Threema\MsgApi\PublicKeyStores\PhpFile('keystore.php');
$publicKeyStore = null;
//create a connection
$connector = new Connection($settings, $publicKeyStore);
$senderPrivateKey = "MY_PUBLIC_KEY_IN_BIN";
$e2eHelper = new \Threema\MsgApi\Helpers\E2EHelper($senderPrivateKey,$connector);
$result = $e2eHelper->sendTextMessage("TEST1234", "This is an end-to-end encrypted message");
if(true === $result->isSuccess()) {
echo 'Message ID: '.$result->getMessageId() . "\n";
}
else {
echo 'Error: '.$result->getErrorMessage() . "\n";
}