Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Codeigniter library to create request send message via API
defined('BASEPATH') or exit('No direct script access allowed');
class Lib_whatsapp
protected $CI;
function __construct()
$this->CI =& get_instance();
public function send_whatsapp($api, $number, $message) {
if (DEMO) {
$this->session->set_flashdata('error', 'Whatsapp are disabled in demo.');
return false;
$date = date('Y-m-d H:i:s');
try {
$client = new \GuzzleHttp\Client();
$wa_base_url = $this->CI->config->item('wa_base_url');
$response = $client->post("$wa_base_url/ssem_api/send_wa_api",
'form_params' => [
'api_key' => $api,
'mobile' => $number,
'reference_id' => 'wanotif', // you can change with your app name
'message' => $message
return true;
} catch (\Exception $e) {
return false;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.