trenalyze / trenalyze
A whatsApp API for sending whatsapp Messages with your own custom phone number
1.2.3
2022-08-13 16:54 UTC
Requires
- php: ^7.1.3 || ^8.0
README
Library Prerequisites
- PHP >= 7X
- WhatsApp account.
- Active Token - Get a Token here.
Installation
Using composer:
$ composer require trenalyze/trenalyze
Note: Add this line of code to your composer.json file
"minimum-stability": "dev",
In PHP:
Note: You'll need to require the Trenalyze PHP Library after installation
// Load the full build. require_once __DIR__ . '/vendor/autoload.php'; use Trenalyze\Trenalyze;
API
1. new Trenalyze(token, sender, true)
Param | Type | Description |
---|---|---|
token | string |
Use your Trenalyze Token from your Dashboard. |
sender | interger |
Enter the WhatApp Number that has already been scanned on the Trenalyze Dashboard. |
debug | boolean |
(OPTIONAL). Default is false. But you can set it to be true and the debug message is passed onto the console. |
// Set The Config $wa = new Trenalyze(YOUR_TRENALYZE_TOKEN_HERE, YOUR_WHATASPP_NUMBER_HERE, true);
Note: Phone number should be in the following format 12345678912
, without +
or any other symbols
2. Initialize needed params in an array
Param | Type | Description |
---|---|---|
receiver | interger |
Phone number should be in the international format 2348157002782 , without + or any other symbols. |
message | interger |
Enter the desired text message to send. |
mediaurl | string |
(OPTIONAL). BUT MUST BE DECLARED This should be a valid media/file link. Learn More |
buttons | array |
(OPTIONAL). BUT MUST BE DECLARED You can attach quick replies buttons to your message. Learn More |
// Set the Required Parameters for sending a message $receiver: '123456789', $message: 'Hello World', $mediaurl: 'https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png', $buttons: [ ['index' => 1, 'urlButton' => ['displayText' => 'Visit my website!', 'url' => 'https://trenalyze.com']], ['index' => 2, 'callButton' => ['displayText' => 'Call me!', 'phoneNumber' => '+1 (234) 5678-9012']], ['index' => 3, 'quickReplyButton' => ['displayText' => 'This is a reply, just like normal buttons!', 'id' => 'id-like-buttons-message']], ];
NOTE: When not using mediaurl and buttons set to NULL
mediaurl: '', buttons: ''
3. Initialize SendMessage
Param | Type | Description |
---|---|---|
receiver | interger |
Phone number should be in the following format 12345678912 , without + or any other symbols. |
message | interger |
Enter the desired text message to send. |
mediaurl | string |
(OPTIONAL). BUT MUST BE DECLARED This should be a valid media/file link. Learn More |
buttons | array |
(OPTIONAL). BUT MUST BE DECLARED You can attach quick replies buttons to your message. Learn More |
// Initialize the send WhatsApp message functions $res = json_decode($wa->sendMessage($receiver, $message, $buttons, $mediaurl));
4. Ensure to get the status of step 3 Action
if ($res->statusCode != 200) { echo $res->message; } else { echo 'WhatsApp Message sent successfully; }