當前位置: 首頁>>代碼示例>>PHP>>正文


PHP WhatsProt::sendGetGroups方法代碼示例

本文整理匯總了PHP中WhatsProt::sendGetGroups方法的典型用法代碼示例。如果您正苦於以下問題:PHP WhatsProt::sendGetGroups方法的具體用法?PHP WhatsProt::sendGetGroups怎麽用?PHP WhatsProt::sendGetGroups使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在WhatsProt的用法示例。


在下文中一共展示了WhatsProt::sendGetGroups方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: 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

示例2: catch

$w->eventManager()->bind('onPresenceUnavailable', 'onPresenceUnavailable');
$w->eventManager()->bind('onGetImage', 'onGetImage');
$w->eventManager()->bind('onGetVideo', 'onGetVideo');
$w->eventManager()->bind('onGetAudio', 'onGetAudio');
$w->connect();
try {
    $w->loginWithPassword($password);
} catch (Exception $e) {
    echo "Error: {$e}";
    exit;
}
echo "\nConnected to WA\n\n";
if ($login == '1') {
    $w->sendGetClientConfig();
    $w->sendGetServerProperties();
    $w->sendGetGroups();
    $w->sendGetBroadcastLists();
    $sql = "UPDATE data SET login=?";
    $query = $db->prepare($sql);
    $query->execute(array('0'));
} else {
    $w->sendGetGroups();
}
//$w->sendGetGroupV2Info();
$w->sendGetPrivacyBlockedList();
$w->sendAvailableForChat($nickname);
$show = true;
global $onlineContacts;
$GLOBALS["online_contacts"] = array();
$GLOBALS["current_contact"];
$pn = new ProcessNode($w, $contact);
開發者ID:jeromez80,項目名稱:dutyPhone,代碼行數:31,代碼來源:pollMessage.php

示例3: getGroupList

 /**
  * Return all groups a user belongs too.
  *
  * Log into the whatsapp servers and return a list
  * of all the groups a user participates in.
  *
  * @return void
  */
 public function getGroupList()
 {
     $this->connectToWhatsApp();
     $this->wa->sendGetGroups();
 }
開發者ID:djade007,項目名稱:WhatsApp,代碼行數:13,代碼來源:WhatsAppApi.php


注:本文中的WhatsProt::sendGetGroups方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。