Send API Whats App Text

This API enables you to send a plain text message to a whats app number

sendText

POST https://backend.payhero.co.ke/api/v2/whatspp/sendText

Sends a text message to a number that you have provided

Headers

NameValue

Content-Type

application/json

Authorization

Basic <token>

Body (JSON)

NameTypeDescription

message

string

The text message to send

phone_number

string

Phone number of the recipient e,g 0787877878

session

string

Your API username, that you used to register the session.

Response

{
    "success": true
}

Sample API Call Code

<?php
$curl = curl_init();
curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://backend.payhero.co.ke/api/v2/whatspp/sendText',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'{
    "message": "My First Text",
    "phone_number": "0787877878",
    "session": "18gdPWKzoXXXX"
}
',
  CURLOPT_HTTPHEADER => array(
    'Content-Type: application/json',
    'Authorization: Basic MThPQ014dGxGeDRuWmdkUFdLem86ZFQ5Vj'
  ),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;

Last updated