<?php defined('BASEPATH') OR exit('No direct script access allowed');

class Whatsapplib {



    protected $_ci;



    // protected $email_pengirim = 'mail@thekecret.masuk.id'; // Isikan dengan email pengirim



    // protected $nama_pengirim = 'Admin'; // Isikan dengan nama pengirim



    // protected $password = '2882edowi92'; // Isikan dengan password email pengirim



    public function __construct(){



        $this->_ci = & get_instance(); // Set variabel _ci dengan Fungsi2-fungsi dari Codeigniter



    }

    public function sendwa($to,$msg){

    	$curl = curl_init();



// $msg = "

// Dear CUCUNYA CUCU,



// Thank you for your trust and using Max Global.

// We inform you that withdrawal has been approved on 2021-09-10 14:57:32

// This is your Indodax voucher detail:



// Withdrawal Amount : 798,-

// Withdrawal Fee : $ 0,-

// Convert to IDR : IDR 10,374,000,000,-

// Total Voucher : IDR 10,374,000,000,-



// Your Indodax voucher code :



// BTC-IDR-EZXNA-FS16W-TMEPT-XT0K3

 

// Please keep your indodax voucher code above safe and secret.

// _____________________________________



// *Top 12 List of Indodax Exchange Partner*

// 📌 	Auto Sultan 

//  	wa.me/6287881818189

// 📌 	Inchanger

//  	wa.me/6285777777999

// 📌 	Boss Voucher

//  	wa.me/6281953535355

// 📌 	King 

//  	wa.me/6282340901200

// 📌 	Maypay

//  	wa.me/628112312348

// 📌 	N Exchange

//  	wa.me/6281905138888

// 📌 	Panda

//  	wa.me/6281953535333

// 📌 	Sifi Exchange

//  	wa.me/6287710576768

// 📌 	Ahas

//  	wa.me/6285749223491

// 📌 	Ayoung

//  	wa.me/6285329236789

// 📌 	Davechanger

//  	wa.me/6282123275744

// 📌 	Triple-R Exchanger

//  	wa.me/6282287268385



// Through the listed exchanges, you can buy voucher from the amount of 1.000 IDR (the exchanges may have their own policy).

// These exchanges provide many methods for buying that will make it easier to buy from them, like bank transfer and/or exchanging e-currency/e-money."  ;



	$host = $this->_ci->config->item('host');

    $token = $this->_ci->config->item('token');

    $deviceid = $this->_ci->config->item('deviceid');

    $devicekey = $this->_ci->config->item('devicekey');



	$dataarr = [

	  // "to" => "6282297087669",

	  // "to" => "6283892422246",

		"to" => $to,

	  	"message" => $msg

	];

	$sendrest = json_encode($dataarr, true);



	curl_setopt_array($curl, [

	  CURLOPT_URL => "$host/messages/send-text",

	  CURLOPT_RETURNTRANSFER => true,

	  CURLOPT_ENCODING => "",

	  CURLOPT_MAXREDIRS => 10,

	  CURLOPT_TIMEOUT => 30,

	  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,

	  CURLOPT_CUSTOMREQUEST => "POST",

	  CURLOPT_POSTFIELDS => $sendrest,

	  CURLOPT_HTTPHEADER => [

	    "Authorization: Bearer $devicekey",

	    "Content-Type: application/json",

	    "device-key: $devicekey"

	  ],

	]);



	$response = curl_exec($curl);

	$err = curl_error($curl);



	curl_close($curl);



	if ($err) {

	  return "cURL Error #:" . $err;

	} else {

	  return $response;

	}

    }

}