Skip to content

Commit

Permalink
Merged.
Browse files Browse the repository at this point in the history
FAK U GIT
  • Loading branch information
shirioko committed Aug 12, 2014
2 parents 46494f3 + 042267a commit 86eb129
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 41 deletions.
14 changes: 7 additions & 7 deletions examples/exampleFunctional.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
########## DO NOT COMMIT THIS FILE WITH YOUR CREDENTIALS ###########
///////////////////////CONFIGURATION///////////////////////
//////////////////////////////////////////////////////////
$username = "**your phone number**"; // Telephone number including the country code without '+' or '00'.
$username = "**your phone number**"; // Telephone number including the country code without '+' or '00'.
$password = "**server generated whatsapp password**"; // A server generated Password you received from WhatsApp. This can NOT be manually created
$identity = "**unique ID generated by WhatsApp client**"; // Obtained during registration with this API or using MissVenom (https://github.com/shirioko/MissVenom) to sniff from your phone.
$nickname = "**your nickname**"; // This is the username (or nickname) displayed by WhatsApp clients.
$identity = "**unique ID generated by WhatsApp client**"; // Obtained during registration with this API or using MissVenom (https://github.com/shirioko/MissVenom) to sniff from your phone.
$nickname = "**your nickname**"; // This is the username (or nickname) displayed by WhatsApp clients.
$target = "**contact's phone number**"; // Destination telephone number including the country code without '+' or '00'.
$debug = false; // Set this to true, to see debug mode.
///////////////////////////////////////////////////////////
Expand Down Expand Up @@ -48,7 +48,7 @@ function onGetProfilePicture($from, $target, $type, $data)
fwrite($fp, $data);
fclose($fp);
}

echo "- Profile picture saved in /".WhatsProt::PICTURES_FOLDER."\n";
}

Expand Down Expand Up @@ -171,7 +171,7 @@ public function process($node)
if ($text && ($text == "5" || trim($text) == "5")) {
$this->wp->sendMessageImage($this->target, "https://s3.amazonaws.com/f.cl.ly/items/2F3U0A1K2o051q1q1e1G/baby-nailed-it.jpg");
$this->wp->sendMessage($this->target, "Congratulations you guessed the right number!");
}
}
elseif (ctype_digit($text)) {
if( (int)$text != "5")
$this->wp->sendMessage($this->target, "I'm sorry, try again!");
Expand All @@ -180,7 +180,7 @@ public function process($node)
$text = $text->getData();
$notify = $node->getAttribute("notify");

echo "\n- ".$notify.": ".$text." ".date('H:i')."\n";
echo "\n- ".$notify.": ".$text." ".date('H:i')."\n";

}
}
68 changes: 34 additions & 34 deletions src/whatsprot.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,9 @@ public function codeRegister($code)

if ($response->status != 'ok') {
$this->eventManager()->fireCodeRegisterFailed(
$this->phoneNumber,
$response->status,
$response->reason,
$this->phoneNumber,
$response->status,
$response->reason,
$response->retry_after
);
if ($this->debug) {
Expand Down Expand Up @@ -343,18 +343,18 @@ public function codeRequest($method = 'sms', $countryCode = null, $langCode = nu
} else if ($response->status != 'sent') {
if (isset($response->reason) && $response->reason == "too_recent") {
$this->eventManager()->fireCodeRequestFailedTooRecent(
$this->phoneNumber,
$method,
$response->reason,
$this->phoneNumber,
$method,
$response->reason,
$response->retry_after
);
$minutes = round($response->retry_after / 60);
throw new Exception("Code already sent. Retry after $minutes minutes.");
} else {
$this->eventManager()->fireCodeRequestFailed(
$this->phoneNumber,
$method,
$response->reason,
$this->phoneNumber,
$method,
$response->reason,
$response->param
);
throw new Exception('There was a problem trying to request the code.');
Expand Down Expand Up @@ -386,10 +386,10 @@ public function connect()
} else {
if ($this->debug) {
print_r("Firing onConnectError\n");
}
}
$this->eventManager()->fireConnectError(
$this->phoneNumber,
$this->socket
$this->phoneNumber,
$this->socket
);
}
}
Expand All @@ -410,7 +410,7 @@ public function disconnect()

/**
* Gets a new micro event dispatcher.
*
*
* @return WhatsAppEvent The event manager.
*/
public function eventManager()
Expand Down Expand Up @@ -1005,7 +1005,7 @@ public function sendMessageAudio($to, $filepath, $storeURLmedia = false)
}
else{
$this->sendRequestFileUpload($fhash, 'audio', $fsize, $filepath, $to);
return true;
return true;
}
}

Expand Down Expand Up @@ -1043,7 +1043,7 @@ public function sendMessageImage($to, $filepath, $storeURLmedia = false, $fsize
}
else{
$this->sendRequestFileUpload($fhash, 'image', $fsize, $filepath, $to);
return true;
return true;
}
}

Expand Down Expand Up @@ -1108,7 +1108,7 @@ protected function sendChatState($to, $state)
* @param bool $storeURLmedia Keep a copy of media file.
* @param int $fsize size of the media file
* @param string $fhash base64 hash of the media file
*
*
* @return bool
*/
public function sendMessageVideo($to, $filepath, $storeURLmedia = false, $fsize = 0, $fhash = "")
Expand All @@ -1121,7 +1121,7 @@ public function sendMessageVideo($to, $filepath, $storeURLmedia = false, $fsize
}
else{
$this->sendRequestFileUpload($fhash, 'video', $fsize, $filepath, $to);
return true;
return true;
}
}

Expand Down Expand Up @@ -1165,7 +1165,7 @@ public function sendPong($msgid)
$messageNode = new ProtocolNode("iq", $messageHash, null, "");
$this->sendNode($messageNode);
$this->eventManager()->fireSendPong(
$this->phoneNumber,
$this->phoneNumber,
$msgid
);
}
Expand Down Expand Up @@ -1196,7 +1196,7 @@ public function sendPresence($type = "active")
$node = new ProtocolNode("presence", $presence, null, "");
$this->sendNode($node);
$this->eventManager()->fireSendPresence(
$this->phoneNumber,
$this->phoneNumber,
$presence['type'],
$this->name
);
Expand Down Expand Up @@ -1298,7 +1298,7 @@ public function sendStatusUpdate($txt)

$this->sendNode($node);
$this->eventManager()->fireSendStatusUpdate(
$this->phoneNumber,
$this->phoneNumber,
$txt
);
}
Expand All @@ -1325,7 +1325,7 @@ public function sendVcard($to, $name, $vCard)
$mediaNode = new ProtocolNode("media", $mediaAttribs, array($vCardNode), "");
$this->sendMessageNode($to, $mediaNode);
}

/**
* Send a vCard to the user/group as Broadcast.
*
Expand Down Expand Up @@ -1384,14 +1384,14 @@ public function uploadFile($file)

if (!empty($url)) {
$this->eventManager()->fireUploadFile(
$this->phoneNumber,
basename($file),
$this->phoneNumber,
basename($file),
$url
);
return $url;
} else {
$this->eventManager()->fireUploadFileFailed(
$this->phoneNumber,
$this->phoneNumber,
basename($file)
);
return false;
Expand Down Expand Up @@ -1867,22 +1867,22 @@ protected function processInboundData($data, $autoReceipt = true)

/**
* Will process the data from the server after it's been decrypted and parsed.
*
*
* This also provides a convenient method to use to unit test the event framework.
*
*
*/
protected function processInboundDataNode(ProtocolNode $node, $autoReceipt = true) {
$this->debugPrint($node->nodeString("rx ") . "\n");
$this->serverReceivedId = $node->getAttribute('id');

if ($node->getTag() == "challenge") {
$this->processChallenge($node);
}
}
elseif($node->getTag() == "failure" )
{

$this->loginStatus = static::DISCONNECTED_STATUS;

}
elseif ($node->getTag() == "success") {
$this->loginStatus = static::CONNECTED_STATUS;
Expand Down Expand Up @@ -2126,7 +2126,7 @@ protected function processInboundDataNode(ProtocolNode $node, $autoReceipt = tru
"paused",
$node->getAttribute('t')
);
}
}
}
if ($node->getTag() == "iq"
&& $node->getAttribute('type') == "get"
Expand Down Expand Up @@ -2396,7 +2396,7 @@ protected function sendNotificationAck($node)
$ack = new ProtocolNode("ack", $attributes, null, null);
$this->sendNode($ack);
}

/**
* Process and save media image
*
Expand Down Expand Up @@ -2508,7 +2508,7 @@ protected function processUploadResponse($node)
$filetype = $duplicate->getAttribute("type");
// $width = $duplicate->getAttribute("width");
// $height = $duplicate->getAttribute("height");
$exploded = explode("/", $url);
$exploded = explode("/", $url);
$filename = array_pop($exploded);
} else {
//upload new file
Expand Down Expand Up @@ -2625,8 +2625,8 @@ public function readStanza()
$error = "socket EOF, closing socket...";
fclose($this->socket);
$this->socket = null;
$this->eventManager()->fireClose(
$this->phoneNumber,
$this->eventManager()->fireClose(
$this->phoneNumber,
$error
);
}
Expand Down

1 comment on commit 86eb129

@ardianys
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😄 😄 😄 maybe it's your editor fault

Please sign in to comment.