Пример #1
0
function sendWhatsapp($target, $message)
{
    $username = "******";
    $password = "******";
    $w = new WhatsProt($username, "דוח סגולה", "A-Report", true);
    $w->connect();
    $w->loginWithPassword($password);
    if (strlen($target) == 8) {
        $target = "9725" . $target;
    } else {
        if (strlen($target) == 10) {
            $target = "972" . substr($target, 1);
        }
    }
    $w->SendPresenceSubscription($target);
    $w->sendMessage($target, $message);
}
Пример #2
0
require_once '../whatsprot.class.php';
$target = @$_POST["target"];
$username = "******";
$password = "******";
$w = new WhatsProt($username, 0, "WhatsApi AJAX Demo", true);
$w->eventManager()->bind("onGetImage", "onGetImage");
$w->eventManager()->bind("onGetProfilePicture", "onGetProfilePicture");
$w->connect();
$w->loginWithPassword($password);
$initial = @$_POST["initial"];
if ($initial == "true" && $target != null) {
    //request contact picture only on first call
    $w->sendGetProfilePicture($target);
}
//subscribe contact status
$w->SendPresenceSubscription($target);
//TODO: presense handling (online/offline/typing/last seen)
while (running($time)) {
    $w->pollMessages();
    running($time);
    //check again if timestamp has been updated
    //check for outbound messages to send:
    session_start();
    $outbound = $_SESSION["outbound"];
    $_SESSION["outbound"] = array();
    session_write_close();
    if (count($outbound) > 0) {
        foreach ($outbound as $message) {
            //send messages
            $w->sendMessage($message["target"], $message["body"]);
            $w->pollMessages();
Пример #3
0
$wa->eventManager()->bind("onPresenceUnavailable", "onPresenceUnavailable");
if ($_SERVER['argv'][1] == "-cRemote0" || $_SERVER['argv'][1] == "-check") {
    echo "\n[-] Tracker mode (ON):\n";
    while (TRUE) {
        if ($_SERVER['argv'][1] == "-check") {
            $wa->sendGetRequestLastSeen($dst);
        } else {
            $wa->sendGetRequestLastSeen($_SERVER['argv'][3]);
            $wa->sendMessage($dst, "(" . $_SERVER['argv'][3] . ") " . $ls);
        }
        sleep(60);
    }
}
if ($_SERVER['argv'][1] == "-cHidden" || $_SERVER['argv'][1] == "-cRemote1") {
    echo "\n[-] Tracker mode (ON): Waiting the user to get online...\n";
    $wa->SendPresenceSubscription($dst);
    $wa->pollMessage();
    if ($presence == "available") {
        echo "- The user is now online\n\n";
    } else {
        echo "- The user is offline\n\n";
    }
    while (true) {
        $wa->pollMessage();
        if ($lastpresence == "available" && $presence == "unavailable") {
            $timeOffline = date("Y-m-d H:i:s");
            while ($presence == "unavailable") {
                $timeDiff = round(strtotime(date("Y-m-d H:i:s")) - strtotime($timeOffline));
                echo secondsToTime($timeDiff) . "\n";
                if ($_SERVER['argv'][1] == "-cRemote1") {
                    $wa->sendMessage($dst, "(" . $_SERVER['argv'][3] . ") " . secondsToTime($timeDiff));
Пример #4
0
 public function send_whatsapp_msg()
 {
     if (!empty($_FILES['image']['name'][0])) {
         $this->upload_files('image');
         exit;
     }
     if (!empty($_FILES['audio']['name'][0])) {
         $this->upload_files('audio');
     }
     if (!empty($_FILES['video']['name'][0])) {
         $this->upload_files('video');
         exit;
     }
     if ($this->input->post('doSend')) {
         require_once 'business_services/whatsapp/vendor/autoload.php';
         $username = $this->config->item('WhatsAppNumber');
         //Mobile Phone prefixed with country code so for india it will be 91xxxxxxxx
         $password = $this->config->item('WhatsAppPassword');
         $w = new WhatsProt($username, 'Mahajyothis', "Mahajyothis", true);
         //Name your application by replacing "WhatsApp Messaging"
         $w->connect();
         $w->loginWithPassword($password);
         $target = $this->input->post('reciepient');
         //Target Phone,reciever phone
         $message = $this->input->post('message');
         $location = $this->input->post('location');
         $latitude = $this->input->post('latitude');
         $longitude = $this->input->post('longitude');
         $w->SendPresenceSubscription($target);
         //Let us first send presence to user
         if ($latitude && $longitude) {
             $w->sendBroadcastLocation($target, $latitude, $longitude, $location);
             // Send Location
         }
         if ($message) {
             $w->sendMessage($target, $message);
         }
         // Send Message
         $this->send_files($w, $target);
         echo json_decode(1);
         exit;
     }
 }