idx
int64
0
241k
question
stringlengths
64
6.21k
target
stringlengths
5
803
900
public function listen ( ) { try { $ isVerificationRequest = $ this -> verifyServices ( ) ; if ( ! $ isVerificationRequest ) { $ this -> fireDriverEvents ( ) ; if ( $ this -> firedDriverEvents === false ) { $ this -> loadActiveConversation ( ) ; if ( $ this -> loadedConversation === false ) { $ this -> callMatchingMess...
Try to match messages with the ones we should listen to .
901
protected function callMatchingMessages ( ) { $ matchingMessages = $ this -> conversationManager -> getMatchingMessages ( $ this -> getMessages ( ) , $ this -> middleware , $ this -> getConversationAnswer ( ) , $ this -> getDriver ( ) ) ; foreach ( $ matchingMessages as $ matchingMessage ) { $ this -> command = $ match...
Call matching message callbacks .
902
protected function callFallbackMessage ( ) { $ messages = $ this -> getMessages ( ) ; if ( ! isset ( $ messages [ 0 ] ) ) { return ; } $ this -> message = $ messages [ 0 ] ; $ this -> fallbackMessage = $ this -> getCallable ( $ this -> fallbackMessage ) ; \ call_user_func ( $ this -> fallbackMessage , $ this ) ; }
Call the fallback method .
903
public function getStoredConversation ( $ message = null ) { if ( is_null ( $ message ) ) { $ message = $ this -> getMessage ( ) ; } $ conversation = $ this -> cache -> get ( $ message -> getConversationIdentifier ( ) ) ; if ( is_null ( $ conversation ) ) { $ conversation = $ this -> cache -> get ( $ message -> getOrig...
Get a stored conversation array from the cache for a given message .
904
public function touchCurrentConversation ( ) { if ( ! is_null ( $ this -> currentConversationData ) ) { $ touched = $ this -> currentConversationData ; $ touched [ 'time' ] = microtime ( ) ; $ this -> cache -> put ( $ this -> message -> getConversationIdentifier ( ) , $ touched , $ this -> config [ 'config' ] [ 'conver...
Touch and update the current conversation .
905
public function removeStoredConversation ( $ message = null ) { if ( $ this -> getStoredConversation ( $ message ) [ 'time' ] == $ this -> currentConversationData [ 'time' ] ) { $ this -> cache -> pull ( $ this -> message -> getConversationIdentifier ( ) ) ; $ this -> cache -> pull ( $ this -> message -> getOriginatedC...
Remove a stored conversation array from the cache for a given message .
906
public function exception ( string $ exception , $ closure ) { $ this -> exceptionHandler -> register ( $ exception , $ this -> getCallable ( $ closure ) ) ; }
Register a custom exception handler .
907
public function get ( $ url , array $ urlParameters = [ ] , array $ headers = [ ] , $ asJSON = false ) { $ request = $ this -> prepareRequest ( $ url , $ urlParameters , $ headers ) ; return $ this -> executeRequest ( $ request ) ; }
Send a get request to a URL .
908
protected static function prepareRequest ( $ url , $ parameters = [ ] , $ headers = [ ] ) { $ request = curl_init ( ) ; if ( $ query = http_build_query ( $ parameters ) ) { $ url .= '?' . $ query ; } curl_setopt ( $ request , CURLOPT_URL , $ url ) ; curl_setopt ( $ request , CURLOPT_RETURNTRANSFER , true ) ; curl_setop...
Prepares a request using curl .
909
public function executeRequest ( $ request ) { $ body = curl_exec ( $ request ) ; $ info = curl_getinfo ( $ request ) ; curl_close ( $ request ) ; $ statusCode = $ info [ 'http_code' ] === 0 ? 500 : $ info [ 'http_code' ] ; return new Response ( ( string ) $ body , $ statusCode , [ ] ) ; }
Executes a curl request .
910
public function applyGroupAttributes ( array $ attributes ) { if ( isset ( $ attributes [ 'middleware' ] ) ) { $ this -> middleware ( $ attributes [ 'middleware' ] ) ; } if ( isset ( $ attributes [ 'driver' ] ) ) { $ this -> driver ( $ attributes [ 'driver' ] ) ; } if ( isset ( $ attributes [ 'recipient' ] ) ) { $ this...
Apply possible group attributes .
911
public function start ( ) : void { if ( $ this -> isReady ( ) ) { $ this -> killExistingFpm ( ) ; } if ( ! is_dir ( dirname ( self :: SOCKET ) ) ) { mkdir ( dirname ( self :: SOCKET ) ) ; } $ this -> fpm = new Process ( [ 'php-fpm' , '--nodaemonize' , '--force-stderr' , '--fpm-config' , $ this -> configFile ] ) ; $ thi...
Start the PHP - FPM process .
912
public function proxy ( $ event ) : LambdaResponse { if ( ! isset ( $ event [ 'httpMethod' ] ) ) { throw new \ Exception ( 'The lambda was not invoked via HTTP through API Gateway: this is not supported by this runtime' ) ; } $ request = $ this -> eventToFastCgiRequest ( $ event ) ; try { $ response = $ this -> client ...
Proxy the API Gateway event to PHP - FPM and return its response .
913
private function killExistingFpm ( ) : void { if ( ! file_exists ( self :: PID_FILE ) ) { unlink ( self :: SOCKET ) ; return ; } $ pid = ( int ) file_get_contents ( self :: PID_FILE ) ; if ( $ pid <= 0 ) { echo "PHP-FPM's PID file contained an invalid PID, assuming PHP-FPM isn't running.\n" ; unlink ( self :: SOCKET ) ...
This methods makes sure to kill any existing PHP - FPM process .
914
private function waitUntilStopped ( int $ pid ) : void { $ wait = 5000 ; $ timeout = 1000000 ; $ elapsed = 0 ; while ( posix_getpgid ( $ pid ) !== false ) { usleep ( $ wait ) ; $ elapsed += $ wait ; if ( $ elapsed > $ timeout ) { throw new \ Exception ( 'Timeout while waiting for PHP-FPM to stop' ) ; } } }
Wait until PHP - FPM has stopped .
915
public function processNextEvent ( callable $ handler ) : void { [ $ event , $ context ] = $ this -> waitNextInvocation ( ) ; try { $ this -> sendResponse ( $ context -> getAwsRequestId ( ) , $ handler ( $ event , $ context ) ) ; } catch ( \ Throwable $ e ) { $ this -> signalFailure ( $ context -> getAwsRequestId ( ) ,...
Process the next event .
916
private function waitNextInvocation ( ) : array { if ( $ this -> handler === null ) { $ this -> handler = curl_init ( "http://{$this->apiUrl}/2018-06-01/runtime/invocation/next" ) ; curl_setopt ( $ this -> handler , CURLOPT_FOLLOWLOCATION , true ) ; curl_setopt ( $ this -> handler , CURLOPT_FAILONERROR , true ) ; } $ c...
Wait for the next lambda invocation and retrieve its data .
917
public function failInitialization ( string $ message , ? \ Throwable $ error = null ) : void { echo "$message\n" ; if ( $ error ) { if ( $ error instanceof \ Exception ) { $ errorMessage = get_class ( $ error ) . ': ' . $ error -> getMessage ( ) ; } else { $ errorMessage = $ error -> getMessage ( ) ; } printf ( "Fatal...
Abort the lambda and signal to the runtime API that we failed to initialize this instance .
918
public function invoke ( string $ functionName , $ event = null ) : InvocationResult { $ rawResult = $ this -> lambda -> invoke ( [ 'FunctionName' => $ functionName , 'LogType' => 'Tail' , 'Payload' => $ event ?? '' , ] ) ; $ resultPayload = $ rawResult -> get ( 'Payload' ) ; $ resultPayload = json_decode ( $ resultPay...
Synchronously invoke a function .
919
public function getCached ( ) { return $ this -> app [ 'cache' ] -> remember ( $ this -> config ( 'cache.key' ) , $ this -> config ( 'cache.lifetime' ) , function ( ) { return $ this -> toCollection ( ) -> toArray ( ) ; } ) ; }
Get cached modules .
920
public function find ( $ name ) { foreach ( $ this -> all ( ) as $ module ) { if ( $ module -> getLowerName ( ) === strtolower ( $ name ) ) { return $ module ; } } return ; }
Find a specific module .
921
public function findByAlias ( $ alias ) { foreach ( $ this -> all ( ) as $ module ) { if ( $ module -> getAlias ( ) === $ alias ) { return $ module ; } } return ; }
Find a specific module by its alias .
922
public function findRequirements ( $ name ) { $ requirements = [ ] ; $ module = $ this -> findOrFail ( $ name ) ; foreach ( $ module -> getRequires ( ) as $ requirementName ) { $ requirements [ ] = $ this -> findByAlias ( $ requirementName ) ; } return $ requirements ; }
Find all modules that are required by a module . If the module cannot be found throw an exception .
923
public function findOrFail ( $ name ) { $ module = $ this -> find ( $ name ) ; if ( $ module !== null ) { return $ module ; } throw new ModuleNotFoundException ( "Module [{$name}] does not exist!" ) ; }
Find a specific module if there return that otherwise throw exception .
924
public function getModulePath ( $ module ) { try { return $ this -> findOrFail ( $ module ) -> getPath ( ) . '/' ; } catch ( ModuleNotFoundException $ e ) { return $ this -> getPath ( ) . '/' . Str :: studly ( $ module ) . '/' ; } }
Get module path for a specific module .
925
public function setUsed ( $ name ) { $ module = $ this -> findOrFail ( $ name ) ; $ this -> app [ 'files' ] -> put ( $ this -> getUsedStoragePath ( ) , $ module ) ; }
Set module used for cli session .
926
public function forgetUsed ( ) { if ( $ this -> app [ 'files' ] -> exists ( $ this -> getUsedStoragePath ( ) ) ) { $ this -> app [ 'files' ] -> delete ( $ this -> getUsedStoragePath ( ) ) ; } }
Forget the module used for cli session .
927
public function install ( $ name , $ version = 'dev-master' , $ type = 'composer' , $ subtree = false ) { $ installer = new Installer ( $ name , $ version , $ type , $ subtree ) ; return $ installer -> run ( ) ; }
Install the specified module .
928
public function run ( ) { $ process = $ this -> getProcess ( ) ; $ process -> setTimeout ( $ this -> timeout ) ; if ( $ this -> console instanceof Command ) { $ process -> run ( function ( $ type , $ line ) { $ this -> console -> line ( $ line ) ; } ) ; } return $ process ; }
Run the installation process .
929
public function getRepoUrl ( ) { switch ( $ this -> type ) { case 'github' : return "git@github.com:{$this->name}.git" ; case 'github-https' : return "https://github.com/{$this->name}.git" ; case 'gitlab' : return "git@gitlab.com:{$this->name}.git" ; break ; case 'bitbucket' : return "git@bitbucket.org:{$this->name}.gi...
Get git repo url .
930
public function getPackageName ( ) { if ( is_null ( $ this -> version ) ) { return $ this -> name . ':dev-master' ; } return $ this -> name . ':' . $ this -> version ; }
Get composer package name .
931
protected function addRelationColumn ( $ key , $ field , $ column ) { $ relatedColumn = Str :: snake ( class_basename ( $ field ) ) . '_id' ; $ method = 'integer' ; return "->{$method}('{$relatedColumn}')" ; }
Add relation column .
932
public function update ( array $ data ) { $ this -> attributes = new Collection ( array_merge ( $ this -> attributes -> toArray ( ) , $ data ) ) ; return $ this -> save ( ) ; }
Update json contents from array data .
933
public function getSeederName ( $ name ) { $ name = Str :: studly ( $ name ) ; $ namespace = $ this -> laravel [ 'modules' ] -> config ( 'namespace' ) ; $ seederPath = GenerateConfigReader :: read ( 'seeder' ) ; $ seederPath = str_replace ( '/' , '\\' , $ seederPath -> getPath ( ) ) ; return $ namespace . '\\' . $ name...
Get master database seeder name for the specified module .
934
public function getSeederNames ( $ name ) { $ name = Str :: studly ( $ name ) ; $ seederPath = GenerateConfigReader :: read ( 'seeder' ) ; $ seederPath = str_replace ( '/' , '\\' , $ seederPath -> getPath ( ) ) ; $ foundModules = [ ] ; foreach ( $ this -> laravel [ 'modules' ] -> config ( 'scan.paths' ) as $ path ) { $...
Get master database seeder name for the specified module under a different namespace than Modules .
935
public function rollback ( ) { $ migrations = $ this -> getLast ( $ this -> getMigrations ( true ) ) ; $ this -> requireFiles ( $ migrations -> toArray ( ) ) ; $ migrated = [ ] ; foreach ( $ migrations as $ migration ) { $ data = $ this -> find ( $ migration ) ; if ( $ data -> count ( ) ) { $ migrated [ ] = $ migration...
Rollback migration .
936
public function reset ( ) { $ migrations = $ this -> getMigrations ( true ) ; $ this -> requireFiles ( $ migrations ) ; $ migrated = [ ] ; foreach ( $ migrations as $ migration ) { $ data = $ this -> find ( $ migration ) ; if ( $ data -> count ( ) ) { $ migrated [ ] = $ migration ; $ this -> down ( $ migration ) ; $ da...
Reset migration .
937
public function publish ( $ name ) { if ( $ name instanceof Module ) { $ module = $ name ; } else { $ module = $ this -> laravel [ 'modules' ] -> findOrFail ( $ name ) ; } with ( new AssetPublisher ( $ module ) ) -> setRepository ( $ this -> laravel [ 'modules' ] ) -> setConsole ( $ this ) -> publish ( ) ; $ this -> li...
Publish assets from the specified module .
938
public function generate ( ) { if ( ! $ this -> filesystem -> exists ( $ path = $ this -> getPath ( ) ) ) { return $ this -> filesystem -> put ( $ path , $ this -> getContents ( ) ) ; } throw new FileAlreadyExistException ( 'File already exists!' ) ; }
Generate the file .
939
protected function installFromFile ( ) { if ( ! file_exists ( $ path = base_path ( 'modules.json' ) ) ) { $ this -> error ( "File 'modules.json' does not exist in your project root." ) ; return ; } $ modules = Json :: make ( $ path ) ; $ dependencies = $ modules -> get ( 'require' , [ ] ) ; foreach ( $ dependencies as ...
Install modules from modules . json file .
940
private function handleOptionalMigrationOption ( ) { if ( $ this -> option ( 'migration' ) === true ) { $ migrationName = 'create_' . $ this -> createMigrationName ( ) . '_table' ; $ this -> call ( 'module:make-migration' , [ 'name' => $ migrationName , 'module' => $ this -> argument ( 'module' ) ] ) ; } }
Create the migration file with the given model if migration flag was used
941
protected function loadMigrationFiles ( $ module ) { $ path = $ this -> laravel [ 'modules' ] -> getModulePath ( $ module ) . $ this -> getMigrationGeneratorPath ( ) ; $ files = $ this -> laravel [ 'files' ] -> glob ( $ path . '/*_*.php' ) ; foreach ( $ files as $ file ) { $ this -> laravel [ 'files' ] -> requireOnce (...
Include all migrations files from the specified module .
942
public function register ( ) { $ this -> registerAliases ( ) ; $ this -> registerProviders ( ) ; if ( $ this -> isLoadFilesOnBoot ( ) === false ) { $ this -> registerFiles ( ) ; } $ this -> fireEvent ( 'register' ) ; }
Register the module .
943
private function getStubName ( ) { if ( $ this -> option ( 'plain' ) === true ) { $ stub = '/controller-plain.stub' ; } elseif ( $ this -> option ( 'api' ) === true ) { $ stub = '/controller-api.stub' ; } else { $ stub = '/controller.stub' ; } return $ stub ; }
Get the stub file name based on the options
944
protected function getReplacement ( $ stub ) { $ replacements = $ this -> module -> config ( 'stubs.replacements' ) ; if ( ! isset ( $ replacements [ $ stub ] ) ) { return [ ] ; } $ keys = $ replacements [ $ stub ] ; $ replaces = [ ] ; foreach ( $ keys as $ key ) { if ( method_exists ( $ this , $ method = 'get' . ucfir...
Get array replacement for the specified stub .
945
public function disconnect ( ) { if ( is_resource ( $ this -> socket ) ) { @ socket_shutdown ( $ this -> socket , 2 ) ; @ socket_close ( $ this -> socket ) ; } $ this -> socket = null ; $ this -> loginStatus = Constants :: DISCONNECTED_STATUS ; $ this -> logFile ( 'info' , 'Disconnected from WA server' ) ; $ this -> ev...
Disconnect from the WhatsApp network .
946
public function loginWithPassword ( $ password ) { $ this -> password = $ password ; if ( is_readable ( $ this -> challengeFilename ) ) { $ challengeData = file_get_contents ( $ this -> challengeFilename ) ; if ( $ challengeData ) { $ this -> challengeData = $ challengeData ; } } $ login = new Login ( $ this , $ this -...
Login to the WhatsApp server with your password .
947
public function pollMessage ( ) { if ( ! $ this -> isConnected ( ) ) { throw new ConnectionException ( 'Connection Closed!' ) ; } $ r = [ $ this -> socket ] ; $ w = [ ] ; $ e = [ ] ; $ s = socket_select ( $ r , $ w , $ e , Constants :: TIMEOUT_SEC , Constants :: TIMEOUT_USEC ) ; if ( $ s ) { if ( $ stanza = $ this -> r...
Fetch a single message node .
948
public function sendGetCipherKeysFromUser ( $ numbers , $ replaceKey = false ) { if ( ! is_array ( $ numbers ) ) { $ numbers = [ $ numbers ] ; } $ this -> replaceKey = $ replaceKey ; $ msgId = $ this -> nodeId [ 'cipherKeys' ] = $ this -> createIqId ( ) ; $ userNode = [ ] ; foreach ( $ numbers as $ number ) { $ userNod...
Send a request to get cipher keys from an user .
949
public function sendBroadcastAudio ( $ targets , $ path , $ storeURLmedia = false , $ fsize = 0 , $ fhash = '' ) { if ( ! is_array ( $ targets ) ) { $ targets = [ $ targets ] ; } return $ this -> sendMessageAudio ( $ targets , $ path , $ storeURLmedia , $ fsize , $ fhash ) ; }
Send a Broadcast Message with audio .
950
public function sendBroadcastImage ( $ targets , $ path , $ storeURLmedia = false , $ fsize = 0 , $ fhash = '' , $ caption = '' ) { if ( ! is_array ( $ targets ) ) { $ targets = [ $ targets ] ; } return $ this -> sendMessageImage ( $ targets , $ path , $ storeURLmedia , $ fsize , $ fhash , $ caption ) ; }
Send a Broadcast Message with an image .
951
public function sendBroadcastLocation ( $ targets , $ long , $ lat , $ name = null , $ url = null ) { if ( ! is_array ( $ targets ) ) { $ targets = [ $ targets ] ; } return $ this -> sendMessageLocation ( $ targets , $ long , $ lat , $ name , $ url ) ; }
Send a Broadcast Message with location data .
952
public function sendBroadcastMessage ( $ targets , $ message ) { $ bodyNode = new ProtocolNode ( 'body' , null , null , $ message ) ; return $ this -> sendBroadcast ( $ targets , $ bodyNode , 'text' ) ; }
Send a Broadcast Message .
953
public function sendBroadcastVideo ( $ targets , $ path , $ storeURLmedia = false , $ fsize = 0 , $ fhash = '' , $ caption = '' ) { if ( ! is_array ( $ targets ) ) { $ targets = [ $ targets ] ; } return $ this -> sendMessageVideo ( $ targets , $ path , $ storeURLmedia , $ fsize , $ fhash , $ caption ) ; }
Send a Broadcast Message with a video .
954
public function sendDeleteBroadcastLists ( $ lists ) { $ msgId = $ this -> createIqId ( ) ; $ listNode = [ ] ; if ( $ lists != null && count ( $ lists ) > 0 ) { for ( $ i = 0 ; $ i < count ( $ lists ) ; $ i ++ ) { $ listNode [ $ i ] = new ProtocolNode ( 'list' , [ 'id' => $ lists [ $ i ] ] , null , null ) ; } } else { ...
Delete Broadcast lists .
955
public function sendClearDirty ( $ categories ) { $ msgId = $ this -> createIqId ( ) ; $ catnodes = [ ] ; foreach ( $ categories as $ category ) { $ catnode = new ProtocolNode ( 'clean' , [ 'type' => $ category ] , null , null ) ; $ catnodes [ ] = $ catnode ; } $ node = new ProtocolNode ( 'iq' , [ 'id' => $ msgId , 'ty...
Clears the dirty status on your account .
956
public function sendChangeNumber ( $ number , $ identity ) { $ msgId = $ this -> createIqId ( ) ; $ usernameNode = new ProtocolNode ( 'username' , null , null , $ number ) ; $ passwordNode = new ProtocolNode ( 'password' , null , null , urldecode ( $ identity ) ) ; $ modifyNode = new ProtocolNode ( 'modify' , null , [ ...
Transfer your number to new one .
957
public function sendGetGroupV2Info ( $ groupID ) { $ msgId = $ this -> nodeId [ 'get_groupv2_info' ] = $ this -> createIqId ( ) ; $ queryNode = new ProtocolNode ( 'query' , [ 'request' => 'interactive' , ] , null , null ) ; $ node = new ProtocolNode ( 'iq' , [ 'id' => $ msgId , 'xmlns' => 'w:g2' , 'type' => 'get' , 'to...
Send a request to get new Groups V2 info .
958
public function sendGetPrivacyBlockedList ( ) { $ msgId = $ this -> nodeId [ 'privacy' ] = $ this -> createIqId ( ) ; $ child = new ProtocolNode ( 'list' , [ 'name' => 'default' , ] , null , null ) ; $ child2 = new ProtocolNode ( 'query' , [ ] , [ $ child ] , null ) ; $ node = new ProtocolNode ( 'iq' , [ 'id' => $ msgI...
Send a request to get a list of people you have currently blocked .
959
public function sendGetPrivacySettings ( ) { $ msgId = $ this -> nodeId [ 'privacy_settings' ] = $ this -> createIqId ( ) ; $ privacyNode = new ProtocolNode ( 'privacy' , null , null , null ) ; $ node = new ProtocolNode ( 'iq' , [ 'to' => Constants :: WHATSAPP_SERVER , 'id' => $ msgId , 'xmlns' => 'privacy' , 'type' =>...
Send a request to get privacy settings .
960
public function sendSetPrivacySettings ( $ category , $ value ) { $ msgId = $ this -> createIqId ( ) ; $ categoryNode = new ProtocolNode ( 'category' , [ 'name' => $ category , 'value' => $ value , ] , null , null ) ; $ privacyNode = new ProtocolNode ( 'privacy' , null , [ $ categoryNode ] , null ) ; $ node = new Proto...
Set privacy of last seen status or profile picture to all contacts or none .
961
public function sendGetProfilePicture ( $ number , $ large = false ) { $ msgId = $ this -> nodeId [ 'getprofilepic' ] = $ this -> createIqId ( ) ; $ hash = [ ] ; $ hash [ 'type' ] = 'image' ; if ( ! $ large ) { $ hash [ 'type' ] = 'preview' ; } $ picture = new ProtocolNode ( 'picture' , $ hash , null , null ) ; $ node ...
Get profile picture of specified user .
962
public function sendGetServerProperties ( ) { $ id = $ this -> createIqId ( ) ; $ child = new ProtocolNode ( 'props' , null , null , null ) ; $ node = new ProtocolNode ( 'iq' , [ 'id' => $ id , 'type' => 'get' , 'xmlns' => 'w' , 'to' => Constants :: WHATSAPP_SERVER , ] , [ $ child ] , null ) ; $ this -> sendNode ( $ no...
Send a request to get the current server properties .
963
public function sendGetServicePricing ( $ lg , $ lc ) { $ msgId = $ this -> createIqId ( ) ; $ pricingNode = new ProtocolNode ( 'pricing' , [ 'lg' => $ lg , 'lc' => $ lc , ] , null , null ) ; $ node = new ProtocolNode ( 'iq' , [ 'id' => $ msgId , 'xmlns' => 'urn:xmpp:whatsapp:account' , 'type' => 'get' , 'to' => Consta...
Send a request to get the current service pricing .
964
public function sendExtendAccount ( ) { $ msgId = $ this -> createIqId ( ) ; $ extendingNode = new ProtocolNode ( 'extend' , null , null , null ) ; $ node = new ProtocolNode ( 'iq' , [ 'id' => $ msgId , 'xmlns' => 'urn:xmpp:whatsapp:account' , 'type' => 'set' , 'to' => Constants :: WHATSAPP_SERVER , ] , [ $ extendingNo...
Send a request to extend the account .
965
public function sendGetBroadcastLists ( ) { $ msgId = $ this -> nodeId [ 'get_lists' ] = $ this -> createIqId ( ) ; $ listsNode = new ProtocolNode ( 'lists' , null , null , null ) ; $ node = new ProtocolNode ( 'iq' , [ 'id' => $ msgId , 'xmlns' => 'w:b' , 'type' => 'get' , 'to' => Constants :: WHATSAPP_SERVER , ] , [ $...
Gets all the broadcast lists for an account .
966
public function sendGetNormalizedJid ( $ countryCode , $ number ) { $ msgId = $ this -> createIqId ( ) ; $ ccNode = new ProtocolNode ( 'cc' , null , null , $ countryCode ) ; $ inNode = new ProtocolNode ( 'in' , null , null , $ number ) ; $ normalizeNode = new ProtocolNode ( 'normalize' , null , [ $ ccNode , $ inNode ] ...
Send a request to get the normalized mobile number representing the JID .
967
public function sendRemoveAccount ( $ lg = null , $ lc = null , $ feedback = null ) { $ msgId = $ this -> createIqId ( ) ; if ( $ feedback != null && strlen ( $ feedback ) > 0 ) { if ( $ lg == null ) { $ lg = '' ; } if ( $ lc == null ) { $ lc = '' ; } $ child = new ProtocolNode ( 'body' , [ 'lg' => $ lg , 'lc' => $ lc ...
Removes an account from WhatsApp .
968
public function sendPing ( ) { $ msgId = $ this -> createIqId ( ) ; $ pingNode = new ProtocolNode ( 'ping' , null , null , null ) ; $ node = new ProtocolNode ( 'iq' , [ 'id' => $ msgId , 'xmlns' => 'w:p' , 'type' => 'get' , 'to' => Constants :: WHATSAPP_SERVER , ] , [ $ pingNode ] , null ) ; $ this -> sendNode ( $ node...
Send a ping to the server .
969
public function sendGetStatuses ( $ jids ) { if ( ! is_array ( $ jids ) ) { $ jids = [ $ jids ] ; } $ children = [ ] ; foreach ( $ jids as $ jid ) { $ children [ ] = new ProtocolNode ( 'user' , [ 'jid' => $ this -> getJID ( $ jid ) ] , null , null ) ; } $ iqId = $ this -> nodeId [ 'getstatuses' ] = $ this -> createIqId...
Get the current status message of a specific user .
970
public function sendGroupsChatCreate ( $ subject , $ participants ) { if ( ! is_array ( $ participants ) ) { $ participants = [ $ participants ] ; } $ participantNode = [ ] ; foreach ( $ participants as $ participant ) { $ participantNode [ ] = new ProtocolNode ( 'participant' , [ 'jid' => $ this -> getJID ( $ particip...
Create a group chat .
971
public function sendSetGroupSubject ( $ gjid , $ subject ) { $ child = new ProtocolNode ( 'subject' , null , null , $ subject ) ; $ node = new ProtocolNode ( 'iq' , [ 'id' => $ this -> createIqId ( ) , 'type' => 'set' , 'to' => $ this -> getJID ( $ gjid ) , 'xmlns' => 'w:g2' , ] , [ $ child ] , null ) ; $ this -> sendN...
Change group s subject .
972
public function sendGroupsLeave ( $ gjids ) { $ msgId = $ this -> nodeId [ 'leavegroup' ] = $ this -> createIqId ( ) ; if ( ! is_array ( $ gjids ) ) { $ gjids = [ $ this -> getJID ( $ gjids ) ] ; } $ nodes = [ ] ; foreach ( $ gjids as $ gjid ) { $ nodes [ ] = new ProtocolNode ( 'group' , [ 'id' => $ this -> getJID ( $ ...
Leave a group chat .
973
public function sendGroupsParticipantsRemove ( $ groupId , $ participant ) { $ msgId = $ this -> createMsgId ( ) ; $ this -> sendGroupsChangeParticipants ( $ groupId , $ participant , 'remove' , $ msgId ) ; }
Remove participant from a group .
974
public function sendPromoteParticipants ( $ gId , $ participant ) { $ msgId = $ this -> createMsgId ( ) ; $ this -> sendGroupsChangeParticipants ( $ gId , $ participant , 'promote' , $ msgId ) ; }
Promote participant of a group ; Make a participant an admin of a group .
975
public function sendDemoteParticipants ( $ gId , $ participant ) { $ msgId = $ this -> createMsgId ( ) ; $ this -> sendGroupsChangeParticipants ( $ gId , $ participant , 'demote' , $ msgId ) ; }
Demote participant of a group ; remove participant of being admin of a group .
976
public function sendNextMessage ( ) { if ( count ( $ this -> outQueue ) > 0 ) { $ msgnode = array_shift ( $ this -> outQueue ) ; $ msgnode -> refreshTimes ( ) ; $ this -> lastId = $ msgnode -> getAttribute ( 'id' ) ; $ this -> sendNode ( $ msgnode ) ; } else { $ this -> lastId = false ; } }
Send the next message .
977
public function sendPong ( $ msgid ) { $ messageNode = new ProtocolNode ( 'iq' , [ 'to' => Constants :: WHATSAPP_SERVER , 'id' => $ msgid , 'type' => 'result' , ] , null , '' ) ; $ this -> sendNode ( $ messageNode ) ; $ this -> eventManager ( ) -> fire ( 'onSendPong' , [ $ this -> phoneNumber , $ msgid , ] ) ; }
Send a pong to the WhatsApp server . I m alive!
978
public function sendPresenceSubscription ( $ to ) { $ node = new ProtocolNode ( 'presence' , [ 'type' => 'subscribe' , 'to' => $ this -> getJID ( $ to ) ] , null , '' ) ; $ this -> sendNode ( $ node ) ; }
Send presence subscription automatically receive presence updates as long as the socket is open .
979
public function sendPresenceUnsubscription ( $ to ) { $ node = new ProtocolNode ( 'presence' , [ 'type' => 'unsubscribe' , 'to' => $ this -> getJID ( $ to ) ] , null , '' ) ; $ this -> sendNode ( $ node ) ; }
Unsubscribe will stop subscription .
980
public function sendSetPrivacyBlockedList ( $ blockedJids = [ ] ) { if ( ! is_array ( $ blockedJids ) ) { $ blockedJids = [ $ blockedJids ] ; } $ items = [ ] ; foreach ( $ blockedJids as $ index => $ jid ) { $ item = new ProtocolNode ( 'item' , [ 'type' => 'jid' , 'value' => $ this -> getJID ( $ jid ) , 'action' => 'de...
Set the list of numbers you wish to block receiving from .
981
public function sendSetRecoveryToken ( $ token ) { $ child = new ProtocolNode ( 'pin' , [ 'xmlns' => 'w:ch:p' , ] , null , $ token ) ; $ node = new ProtocolNode ( 'iq' , [ 'id' => $ this -> createIqId ( ) , 'type' => 'set' , 'to' => Constants :: WHATSAPP_SERVER , ] , [ $ child ] , null ) ; $ this -> sendNode ( $ node )...
Set the recovery token for your account to allow you to retrieve your password at a later stage .
982
public function sendStatusUpdate ( $ txt ) { $ child = new ProtocolNode ( 'status' , null , null , $ txt ) ; $ nodeID = $ this -> createIqId ( ) ; $ node = new ProtocolNode ( 'iq' , [ 'to' => Constants :: WHATSAPP_SERVER , 'type' => 'set' , 'id' => $ nodeID , 'xmlns' => 'status' , ] , [ $ child ] , null ) ; $ this -> s...
Update the user status .
983
public function rejectCall ( $ to , $ id , $ callId ) { $ rejectNode = new ProtocolNode ( 'reject' , [ 'call-id' => $ callId , ] , null , null ) ; $ callNode = new ProtocolNode ( 'call' , [ 'id' => $ id , 'to' => $ this -> getJID ( $ to ) , ] , [ $ rejectNode ] , null ) ; $ this -> sendNode ( $ callNode ) ; }
Rejects a call .
984
protected function createMsgId ( ) { $ msg = hex2bin ( $ this -> messageId ) ; $ chars = str_split ( $ msg ) ; $ chars_val = array_map ( 'ord' , $ chars ) ; $ pos = count ( $ chars_val ) - 1 ; while ( true ) { if ( $ chars_val [ $ pos ] < 255 ) { $ chars_val [ $ pos ] ++ ; break ; } else { $ chars_val [ $ pos ] = 0 ; $...
Create a unique msg id .
985
public function createIqId ( ) { $ iqId = $ this -> iqCounter ; $ this -> iqCounter ++ ; $ id = dechex ( $ iqId ) ; return $ id ; }
iq id .
986
public function debugPrint ( $ debugMsg ) { if ( $ this -> debug ) { if ( is_array ( $ debugMsg ) || is_object ( $ debugMsg ) ) { print_r ( $ debugMsg ) ; } else { echo $ debugMsg ; } return true ; } return false ; }
Print a message to the debug console .
987
public function isLoggedIn ( ) { return $ this -> isConnected ( ) && ! empty ( $ this -> loginStatus ) && $ this -> loginStatus === Constants :: CONNECTED_STATUS ; }
Have we an active connection with WhatsAPP AND a valid login already?
988
protected function getMediaFile ( $ filepath , $ maxsizebytes = 5242880 ) { if ( filter_var ( $ filepath , FILTER_VALIDATE_URL ) !== false ) { $ this -> mediaFileInfo = [ ] ; $ this -> mediaFileInfo [ 'url' ] = $ filepath ; $ media = file_get_contents ( $ filepath ) ; $ this -> mediaFileInfo [ 'filesize' ] = strlen ( $...
Retrieves media file and info from either a URL or localpath .
989
protected function processInboundData ( $ data ) { $ node = $ this -> reader -> nextTree ( $ data ) ; if ( $ node != null ) { $ this -> processInboundDataNode ( $ node ) ; } }
Process inbound data .
990
protected function processMediaImage ( $ node ) { $ media = $ node -> getChild ( 'media' ) ; if ( $ media != null ) { $ filename = $ media -> getAttribute ( 'file' ) ; $ url = $ media -> getAttribute ( 'url' ) ; file_put_contents ( $ this -> dataFolder . Constants :: MEDIA_FOLDER . DIRECTORY_SEPARATOR . 'thumb_' . $ fi...
Process and save media image .
991
protected function processProfilePicture ( $ node ) { $ pictureNode = $ node -> getChild ( 'picture' ) ; if ( $ pictureNode != null ) { if ( $ pictureNode -> getAttribute ( 'type' ) == 'preview' ) { $ filename = $ this -> dataFolder . Constants :: PICTURES_FOLDER . DIRECTORY_SEPARATOR . 'preview_' . $ node -> getAttrib...
Processes received picture node .
992
protected function processTempMediaFile ( $ storeURLmedia ) { if ( ! isset ( $ this -> mediaFileInfo [ 'url' ] ) ) { return false ; } if ( $ storeURLmedia && is_file ( $ this -> mediaFileInfo [ 'filepath' ] ) ) { rename ( $ this -> mediaFileInfo [ 'filepath' ] , $ this -> mediaFileInfo [ 'filepath' ] . '.' . $ this -> ...
If the media file was originally from a URL this function either deletes it or renames it depending on the user option .
993
public function readStanza ( ) { $ buff = '' ; if ( $ this -> isConnected ( ) ) { $ header = @ socket_read ( $ this -> socket , 3 ) ; if ( $ header === false ) { $ this -> eventManager ( ) -> fire ( 'onClose' , [ $ this -> phoneNumber , 'Socket EOF' , ] ) ; } if ( strlen ( $ header ) == 0 ) { return ; } if ( strlen ( $...
Read 1024 bytes from the whatsapp server .
994
protected function sendCheckAndSendMedia ( $ filepath , $ maxSize , $ to , $ type , $ allowedExtensions , $ storeURLmedia , $ caption = '' ) { if ( $ this -> getMediaFile ( $ filepath , $ maxSize ) == true ) { if ( in_array ( strtolower ( $ this -> mediaFileInfo [ 'fileextension' ] ) , $ allowedExtensions ) ) { $ b64ha...
Checks that the media file to send is of allowable filetype and within size limits .
995
protected function sendBroadcast ( $ targets , $ node , $ type ) { if ( ! is_array ( $ targets ) ) { $ targets = [ $ targets ] ; } $ toNodes = [ ] ; foreach ( $ targets as $ target ) { $ jid = $ this -> getJID ( $ target ) ; $ hash = [ 'jid' => $ jid ] ; $ toNode = new ProtocolNode ( 'to' , $ hash , null , null ) ; $ t...
Send a broadcast .
996
public function sendData ( $ data ) { if ( $ this -> isConnected ( ) ) { if ( socket_write ( $ this -> socket , $ data , strlen ( $ data ) ) === false ) { $ this -> eventManager ( ) -> fire ( 'onClose' , [ $ this -> phoneNumber , 'Connection closed!' , ] ) ; } } }
Send data to the WhatsApp server .
997
protected function sendGetGroupsFiltered ( $ type ) { $ msgID = $ this -> nodeId [ 'getgroups' ] = $ this -> createIqId ( ) ; $ child = new ProtocolNode ( $ type , null , null , null ) ; $ node = new ProtocolNode ( 'iq' , [ 'id' => $ msgID , 'type' => 'get' , 'xmlns' => 'w:g2' , 'to' => Constants :: WHATSAPP_GROUP_SERV...
Send the getGroupList request to WhatsApp .
998
protected function sendGroupsChangeParticipants ( $ groupId , $ participant , $ tag , $ id ) { $ participants = new ProtocolNode ( 'participant' , [ 'jid' => $ this -> getJID ( $ participant ) ] , null , '' ) ; $ childHash = [ ] ; $ child = new ProtocolNode ( $ tag , $ childHash , [ $ participants ] , '' ) ; $ node = n...
Change participants of a group .
999
protected function sendMessageNode ( $ to , $ node , $ id = null , $ plaintextNode = null ) { $ msgId = ( $ id == null ) ? $ this -> createMsgId ( ) : $ id ; $ to = $ this -> getJID ( $ to ) ; if ( $ node -> getTag ( ) == 'body' || $ node -> getTag ( ) == 'enc' ) { $ type = 'text' ; } else { $ type = 'media' ; } $ mess...
Send node to the servers .