Download the PHP package rugk/threema-msgapi-sdk-php without Composer
On this page you can find all versions of the php package rugk/threema-msgapi-sdk-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download rugk/threema-msgapi-sdk-php
More information about rugk/threema-msgapi-sdk-php
Files in rugk/threema-msgapi-sdk-php
Package threema-msgapi-sdk-php
Short Description Threema PHP-SDK to integrate Threema Gateway in your environment. This SDK allows you to send end-to-end-encrypted messages to Threema users using the Threema Gateway.
License MIT
Homepage https://gateway.threema.ch/en/developer/sdk-php
Informations about the package threema-msgapi-sdk-php
Threema Gateway PHP SDK
Version: 1.2.0
Notes about this version
This is a fork of the original repo after it was announced that the GitHub-version is no longer maintained by Threema.
As this is the community version of the Threema Gateway PHP SDK it may contain additional changes which are not yet included in the official downloadable version on the Threema website. If you are looking for a simple mirror of the downloadable Threema version you can switch to the branch official
.
More information is avaliable in the wiki.
An automatically created documentation of this SDK can be found on GitHub Pages.
The contributors of this repository are not affiliated with Threema or the Threema GmbH.
Installation
- Install PHP 5.4 or later: https://secure.php.net/manual/en/install.php
-
For better encryption performance, install the libsodium PHP extension.
This step is optional; if the libsodium PHP extension is not available, the SDK will automatically fall back to (slower) pure PHP code for ECC encryption (file and image sending not supported).
A 64bit version of PHP is required for pure PHP encryption.
To install the libsodium PHP extension:
Then add the following line to your php.ini file:
If you want to check whether your server meets the requirements and everything is configured properly you can execute threema-msgapi-tool.php
without any parameters on the console or point your browser to the location where it is saved on your server.
If you want to use this library in your own product it is recommend to use Composer and require rugk/threema-msgapi-sdk-php
.
SDK usage
Creating a connection
Creating a connection with advanced options
Attention: These settings change internal values of the TLS connection. Choosing wrong settings can weaken the TLS connection or prevent a successful connection to the server. Use them with care!
Each of the additional options shown below is optional. You can leave it out or use null
to use the default value determinated by cURL for this option.
If you want to get a list of all ciphers you can use have a look at the SSLLabs scan, at the list of all available OpenSSL ciphers and the comparison table by Mozilla which also has some suggestions for good ciphers you should use.
Note: For pinnedKey
to work you must install cURL 7.39 or higher. It is also recommend to use PHP 7.0.7 or higher if you want to support this feature, but it is not required.
You can test whether it works by specifying an invalid pin.
Sending a text message to a Threema ID (Simple Mode)
Sending a text message to a Threema ID (E2E Mode)
Sending a file message to a Threema ID (E2E Mode)
Console client usage
Local operations (no network communication)
Encrypt
Encrypt standard input using the given sender private key and recipient public key. Two lines to standard output: first the nonce (hex), and then the box (hex).
Decrypt
Decrypt standard input using the given recipient private key and sender public key. The nonce must be given on the command line, and the box (hex) on standard input. Prints the decrypted message to standard output.
Hash Email Address
Hash an email address for identity lookup. Prints the hash in hex.
Hash Phone Number
Hash a phone number for identity lookup. Prints the hash in hex.
Generate Key Pair
Generate a new key pair and write the private and public keys to the respective files (in hex).
Derive Public Key
Derive the public key that corresponds with the given private key.
Network operations
Send Simple Message
Send a message from standard input with server-side encryption to the given ID. <from>
is the API identity and <secret>
is the API secret. the message ID on success.
Send End-to-End Encrypted Text Message
Encrypt standard input and send the text message to the given ID. <from>
is the API identity and <secret>
is the API secret. Prints the message ID on success.
Send a End-to-End Encrypted Image Message
Encrypt the image file and send the message to the given ID. <from>
is the API identity and <secret>
is the API secret. Prints the message ID on success.
Send a End-to-End Encrypted File Message
Encrypt the file (and thumbnail if given) and send the message to the given ID. <from>
is the API identity and <secret>
is the API secret. Prints the message ID on success.
ID-Lookup By Email Address
Lookup the ID linked to the given email address (will be hashed locally).
ID-Lookup By Phone Number
Lookup the ID linked to the given phone number (will be hashed locally).
Fetch Public Key
Lookup the public key for the given ID.
Fetch Capability
Fetch the capabilities of a Threema ID.
Decrypt a Message and download the Files
Decrypt a box (must be provided on stdin) message and download (if the message is an image or file message) the file(s) to the given <outputFolder>
folder.
Remaining credits
Fetch remaining credits.
Contributing
Nice to see you want to contribute. We may periodically send patches to Threema to make it possible for them to implement them in the official SDK version.
You can find more information in our wiki.
Implementations
Looking for some implementations? Have a look at the wiki.
Other platforms (Java and Python)
All repositories on GitHub are no longer maintained by the Threema GmbH. However, the community has forked the repositories of all platforms and they are now maintained unofficially.
You can find the Java repository at simmac/threema-msgapi-sdk-java
and the Python repository at lgrahl/threema-msgapi-sdk-python.