Codeigniter library to create request send message via send.wanotif.com API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
defined('BASEPATH') or exit('No direct script access allowed'); | |
class Lib_whatsapp | |
{ | |
protected $CI; | |
function __construct() | |
{ | |
$this->CI =& get_instance(); | |
$this->CI->load->config('whatsapp'); | |
} | |
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) { | |
$this->set_error($e->getMessage()); | |
return false; | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment