当前位置: 首页>>代码示例>>PHP>>正文


PHP WhatsProt::sendSync方法代码示例

本文整理汇总了PHP中WhatsProt::sendSync方法的典型用法代码示例。如果您正苦于以下问题:PHP WhatsProt::sendSync方法的具体用法?PHP WhatsProt::sendSync怎么用?PHP WhatsProt::sendSync使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WhatsProt的用法示例。


在下文中一共展示了WhatsProt::sendSync方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: WhatsProt

}
echo "[] logging in as '{$nickname}' ({$username})\n";
$w = new WhatsProt($username, $nickname, $debug);
$w->eventManager()->bind('onPresenceAvailable', 'onPresenceAvailable');
$w->eventManager()->bind('onPresenceUnavailable', 'onPresenceUnavailable');
$w->connect();
// Nos conectamos a la red de WhatsApp
$w->loginWithPassword($password);
// Iniciamos sesion con nuestra contraseña
echo "[*]Conectado a WhatsApp\n\n";
$w->sendGetServerProperties();
// Obtenemos las propiedades del servidor
$w->sendClientConfig();
// Enviamos nuestra configuración al servidor
$sync = [$target];
$w->sendSync($sync);
// Sincronizamos el contacto
$w->pollMessage();
// Volvemos a poner en cola mensajes
$w->sendPresenceSubscription($target);
// Nos suscribimos a la presencia del usuario
$pn = new ProcessNode($w, $target);
$w->setNewMessageBind($pn);
while (1) {
    $w->pollMessage();
    $msgs = $w->getMessages();
    foreach ($msgs as $m) {
        // process inbound messages
        //print($m->NodeString("") . "\n");
    }
    $line = fgets_u(STDIN);
开发者ID:jonathan-r,项目名称:Chat-API,代码行数:31,代码来源:Simple+CLI+client.php

示例2: switch

 $mainCmd = fgets_u(STDIN);
 switch ($mainCmd) {
     case '/add':
         echo "\nEnter the number you want to add > ";
         $numberToAdd = trim(fgets(STDIN));
         do {
             echo "\nIs it right yes/no > ";
             $check = trim(fgets(STDIN));
             if ($check != 'yes') {
                 echo "\nEnter the number you want to add > ";
                 $numberToAdd = trim(fgets(STDIN));
             }
         } while ($check != 'yes');
         echo "\nEnter the nickname/name > ";
         $nickname = trim(fgets(STDIN));
         $w->sendSync([$numberToAdd], null, 3);
         if ($existUser) {
             $w->sendPresenceSubscription($numberToAdd);
             addContact($numberToAdd, $nickname);
         }
         break;
     case '/delete':
         echo "\nEnter the nickname you want to remove > ";
         $nickname = trim(fgets(STDIN));
         do {
             echo "\nIs it right yes/no > ";
             $check = trim(fgets(STDIN));
             if ($check != 'yes') {
                 echo "\nEnter the nickname you want to remove > ";
                 $nickname = trim(fgets(STDIN));
             }
开发者ID:MattPorto,项目名称:Chat-API,代码行数:31,代码来源:client.php

示例3: onSyncResult

        //add leading +
        $number = "+{$number}";
    }
    $numbers[] = $number;
}
//event handler
/**
 * @param $result SyncResult
 */
function onSyncResult($result)
{
    foreach ($result->existing as $number) {
        echo "{$number} exists<br />";
    }
    foreach ($result->nonExisting as $number) {
        echo "{$number} does not exist<br />";
    }
    die;
    //to break out of the while(true) loop
}
$wa = new WhatsProt($username, "", "WhatsApp", false);
//bind event handler
$wa->eventManager()->bind('onGetSyncResult', 'onSyncResult');
$wa->connect();
$wa->loginWithPassword($password);
//send dataset to server
$wa->sendSync($numbers);
//wait for response
while (true) {
    $wa->pollMessage();
}
开发者ID:micschk,项目名称:WhatsAPI,代码行数:31,代码来源:contactsync.php

示例4: fire

 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     if (!$this->argument('number')) {
         return $this->error('No number specified.');
     }
     $number = Number::where('number', $this->argument('number'))->first();
     if (is_null($number) || is_null($number->wa_password) || is_null($number->wa_expiration)) {
         return $this->error('Whatsapp not registered. Run php artisan whatsapp:register');
     }
     $contacts = $number->contacts->map(function ($contact) {
         return $contact->number;
     });
     $wa = new WhatsProt($number->number, $number->number, true);
     $wa->connect();
     // Connects to WhatsApp
     $wa->loginWithPassword($number->wa_password);
     // Login
     $wa->pollMessage();
     $wa->sendGetPrivacyBlockedList();
     // Get our privacy list
     $wa->sendGetClientConfig();
     // Get client config
     $wa->sendGetServerProperties();
     // Get server properties
     if (!$contacts->isEmpty()) {
         $wa->sendGetHasVoipEnabled($contacts);
     }
     // Get which users have voip enabled
     $wa->sendGetGroups();
     // Get groups (participating)
     $wa->sendGetBroadcastLists();
     // Get broadcasts lists
     // $wa->sendGetProfilePicture(self); // self preview profile picture [OPTIONAL]
     if (!$contacts->isEmpty()) {
         $wa->sendSync($contacts);
     }
     // Sync all contacts
     // $wa->sendGetStatuses(All contacts); // Get contacts status [OPTIONAL]
     /*
     for (All contacts) [OPTIONAL]
     {
       			$wa->sendGetProfilePicture(contact); // preview profile picture of every contact
     }
     */
     // $wa->sendPing(); // Keep alive
     $wa->eventManager()->bind("onGetMessage", function ($mynumber, $from, $id, $type, $time, $name, $body) {
         // todo // save message id and compare to avoid duplicate
         $inbound = new Inbound();
         $inbound->from = $this->getFrom($from);
         $inbound->to = $mynumber;
         $inbound->text = $body;
         $inbound->type = 'whatsapp';
         $inbound->save();
     });
     $wa->eventManager()->bind("onPresenceAvailable", function ($mynumber, $from) {
         $from = $this->getFrom($from);
         // todo // add or update wa-contact
     });
     $wa->eventManager()->bind("onPresenceUnavailable", function ($mynumber, $from, $last) {
         $from = $this->getFrom($from);
         // todo // add or update wa-contact
     });
     $wa->eventManager()->bind("onMessageReceivedClient", function ($mynumber, $from, $id) {
         $outbound_chunk = OutboundChunk::where('message_id', $id)->first();
         if (!$outbound_chunk) {
             return;
         }
         $outbound_chunk->dn_error_code = 0;
         $outbound_chunk->dn_status = 'delivered';
         $outbound_chunk->save();
     });
     $time = time();
     while (true) {
         sleep(1);
         $wa->pollMessage();
         $this->processMessages($wa);
         if (time() - $time >= 8) {
             $wa->sendActiveStatus();
             $time = time();
             // whatsapp command action
             $whatsAppAction = Cache::get('whatsAppAction_' . $number->number, false);
             if ($whatsAppAction) {
                 $whatsAppActionInput = Cache::get('whatsAppActionInput_' . $number->number, false);
                 Cache::forget('whatsAppAction_' . $number->number);
                 Cache::forget('whatsAppActionInput_' . $number->number);
                 switch (strtolower($whatsAppAction)) {
                     case 'updatestatus':
                         $wa->sendStatusUpdate($whatsAppActionInput);
                         break;
                     case 'setprofilepicture':
                         try {
                             $wa->sendSetProfilePicture($whatsAppActionInput);
                         } catch (Exception $e) {
                         }
                         break;
//.........这里部分代码省略.........
开发者ID:aa6my,项目名称:nexmo-dashboard,代码行数:101,代码来源:WhatsAppStart.php

示例5: switch

 $mainCmd = fgets_u(STDIN);
 switch ($mainCmd) {
     case '/add':
         echo "\nEnter the number you want to add > ";
         $numberToAdd = trim(fgets(STDIN));
         do {
             echo "\nIs it right yes/no > ";
             $check = trim(fgets(STDIN));
             if ($check != 'yes') {
                 echo "\nEnter the number you want to add > ";
                 $numberToAdd = trim(fgets(STDIN));
             }
         } while ($check != 'yes');
         echo "\nEnter the nickname/name > ";
         $nickname = trim(fgets(STDIN));
         $w->sendSync(array($numberToAdd), null, 3);
         if ($existUser) {
             $w->sendPresenceSubscription($numberToAdd);
             addContact($numberToAdd, $nickname);
         }
         break;
     case '/delete':
         echo "\nEnter the nickname you want to remove > ";
         $nickname = trim(fgets(STDIN));
         do {
             echo "\nIs it right yes/no > ";
             $check = trim(fgets(STDIN));
             if ($check != 'yes') {
                 echo "\nEnter the nickname you want to remove > ";
                 $nickname = trim(fgets(STDIN));
             }
开发者ID:Thomblin,项目名称:Chat-API,代码行数:31,代码来源:client.php


注:本文中的WhatsProt::sendSync方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。