Ejemplo n.º 1
0
 public function sendEmail($mail)
 {
     $setting = Setting::find()->where(['id' => 1])->one();
     $username = $setting->sendgridUsername;
     $password = $setting->sendgridPassword;
     $mail_admin = $setting->emailAdmin;
     $sendgrid = new \SendGrid($username, $password, array("turn_off_ssl_verification" => true));
     $email = new \SendGrid\Email();
     $subject = 'Registrasi Berhasil';
     $body = 'Thanks ' . $this->username . ',';
     $body .= "\n";
     $body .= "Registrasi anda berhasil, kami akan segera mereview kembali registrasi anda. \n";
     $body .= "Thanks, \n";
     $body .= Yii::$app->name;
     $email->addTo($mail)->setFrom($mail_admin)->setSubject('Registrasi berhasil')->setHtml($body)->addCategory("registrasi");
     $response = $sendgrid->send($email);
     //return $response;
     //send whatsapp
     if ($setting->whatsappNumber && $setting->whatsappPassword) {
         $number = $setting->whatsappNumber;
         $app = Yii::$app->name;
         $password = $setting->whatsappPassword;
         $w = new WhatsApp($number, $app, $password);
         $w->send($setting->whatsappSend, $body);
     }
 }
Ejemplo n.º 2
0
 public static function get()
 {
     if (!isset(self::$instance)) {
         self::$instance = new WhatsApp();
     }
     return self::$instance;
 }
Ejemplo n.º 3
0
<?php

require "whatsapp.v2.php";
// DEMO OF USAGE
$wa = new WhatsApp("full number without + or 00", "password");
$wa->Connect();
$wa->Login();
// SEND FILE TEST
// sendImage($msgid,$to,$path,$size,$link,$b64thumb);
$link = "http://onetoanother.com/images/comingsoon.jpg";
$thumb = file_get_contents("demo/x3.jpg");
$b64thumb = base64_encode($thumb);
$wa->sendImage(time() . "-1", "973xxxxxx", "ccf7b9444a511639efd998260b712253.jpg", "9999", $link, $b64thumb);
////// END SEND FILE TEST
// SEND AN EMOJI TEST
$str = "tgas [emo]EE808A[/emo] wtwet [emo]EE808C[/emo]";
function parsEmo($matches)
{
    return hex2str($matches[1]);
}
$bbcode = preg_replace_callback("#\\[emo\\](.+)\\[\\/emo\\]#iUs", "parsEmo", $str);
$wa->Message(time() . "-1", "97366666666", "{$bbcode}");
//$wa->RequestLastSeen("9733110772");