Skip to content

Commit

Permalink
Updated README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
shirioko committed Jul 15, 2013
1 parent b593453 commit 44a804f
Showing 1 changed file with 48 additions and 46 deletions.
94 changes: 48 additions & 46 deletions EVENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Available events and arguments
==============================
- onClose:
- phone: The user phone number including the country code.
- error: The message error.
- error: The error message.
- onCodeRegister:
- phone: The user phone number including the country code.
- login: Phone number with country code.
Expand All @@ -18,21 +18,21 @@ Available events and arguments
- phone: The user phone number including the country code.
- status: The server status number
- reason: Reason of the status (e.g. too_recent/missing_param/bad_param).
- retry_after: Waiting time before requesting a new code.
- retry_after: Waiting time before requesting a new code in seconds.
- onCodeRequest:
- phone: The user phone number including the country code.
- method: Used method.
- method: Used method (SMS/voice).
- length: Registration code length.
- onCodeRequestFailed:
- phone: The user phone number including the country code.
- method: Used method.
- method: Used method (SMS/voice).
- reason: Reason of the status (e.g. too_recent/missing_param/bad_param).
- value: The missing_param/bad_param or waiting time before requesting a new code.
- onCodeRequestFailedTooRecent:
- phone: The user phone number including the country code.
- method: Used method.
- reason: Reason of the status (e.g. too_recent/missing_param/bad_param).
- retry_after: Waiting time before requesting a new code.
- method: Used method (SMS/voice).
- reason: Reason of the status (too_recent).
- retry_after: Waiting time before requesting a new code in seconds.
- onConnect:
- phone: The user phone number including the country code.
- sokect: The resource socket id.
Expand All @@ -57,8 +57,10 @@ Available events and arguments
- onDissectPhone
- phone: The user phone number including the country code.
- country: The detected country name.
- cc: The user country code without the country code.
- phone: The user phone number.
- cc: The number's country code.
- mcc: International cell network code for the detected country.
- lc: Location code for the detected country
- lg: Language code for the detected country
- onDissectPhoneFailed:
- phone: The user phone number including the country code.
- onGetAudio:
Expand All @@ -77,7 +79,7 @@ Available events and arguments
- acodec: The audio codec.
- onGetError:
- phone: The user phone number including the country code.
- error: Array with error data for why request was not successful.
- error: Array with error data for why request failed.
- onGetGroups:
- phone: The user phone number including the country code.
- groupList: Array with all the groups and groupsinfo.
Expand All @@ -86,15 +88,15 @@ Available events and arguments
- groupList: Array with the the groupinfo.
- onGetGroupsSubject:
- phone: The user phone number including the country code.
- gId: The group id.
- gId: The group JID.
- time: The unix time when send subject.
- author: The author phone number including the country code.
- participant: The participant phone number including the country code.
- name: The sender name.
- subject: The subject.
- subject: The subject (e.g. group name).
- onGetImage:
- phone: The user phone number including the country code.
- from: The sender phone number.
- from: The sender JID.
- msgid: The message id.
- type: The message type.
- time: The unix time when send message notification.
Expand All @@ -109,7 +111,7 @@ Available events and arguments
- thumbnail: The base64_encode image thumbnail.
- onGetLocation:
- phone: The user phone number including the country code.
- from: The sender phone number.
- from: The sender JID.
- msgid: The message id.
- type: The message type.
- time: The unix time when send message notification.
Expand All @@ -121,31 +123,31 @@ Available events and arguments
- thumbnail: The base64_encode location image thumbnail.
- onGetMessage:
- phone: The user phone number including the country code.
- from: The sender phone number.
- from: The sender JID.
- msgid: The message id.
- type: The message type.
- time: The unix time when send message notification.
- name: The sender name.
- message: The message.
- onGetPrivacyBlockedList:
- phone: The user phone number including the country code.
- data: Array of data node containing numbers you have blocked.
- data: Array of data nodes containing numbers you have blocked.
- onGetProfilePicture:
- phone: The user phone number including the country code.
- from: The sender phone number.
- type: The type of picture.
- thumbnail: The base64_encode image.
- from: The sender JID.
- type: The type of picture (image/preview).
- thumbnail: The base64_encoded image.
- onGetRequestLastSeen:
- phone: The user phone number including the country code.
- msgid: The message id.
- sec: The number of seconds seen last seen online.
- sec: The number of seconds since the user went offline.
- onGetServerProperties:
- phone: The user phone number including the country code.
- version: The version number on the server.
- properties: Array of server properties.
- onGetvCard:
- phone: The user phone number including the country code.
- from: The sender phone number.
- from: The sender JID.
- msgid: The message id.
- type: The message type.
- time: The unix time when send message notification.
Expand All @@ -154,7 +156,7 @@ Available events and arguments
- vcard: The vCard.
- onGetVideo:
- phone: The user phone number including the country code.
- from: The sender phone number.
- from: The sender JID.
- msgid: The message id.
- type: The message type.
- time: The unix time when send message notification.
Expand All @@ -170,42 +172,42 @@ Available events and arguments
- thumbnail: The base64_encode video thumbnail.
- onGroupsChatCreate:
- phone: The user phone number including the country code.
- gId: The group id.
- gId: The group JID.
- onGroupsChatEnd:
- phone: The user phone number including the country code.
- gId: The group id.
- gId: The group JID.
- onGroupsParticipantsAdd:
- phone: The user phone number including the country code.
- groupId: The groupId.
- participant: The participant phone number including the country code.
- groupId: The group JID.
- participant: The participant JID.
- onGroupsParticipantsRemove:
- phone: The user phone number including the country code.
- groupId: The groupId.
- participant: The participant phone number including the country code.
- author: The author phone number including the country code.
- groupId: The group JID.
- participant: The participant JID.
- author: The author JID.
- onLogin:
- phone: The user phone number including the country code.
- onMessageComposing:
- phone: The user phone number including the country code.
- from: The sender phone number.
- from: The sender JID.
- msgid: The message id.
- type: The message type.
- time: The unix time when send message notification.
- onMessagePaused:
- phone: The user phone number including the country code.
- from: The sender phone number.
- from: The sender JID.
- msgid: The message id.
- type: The message type.
- time: The unix time when send message notification.
- onMessageReceivedClient:
- phone: The user phone number including the country code.
- from: The sender phone number.
- from: The sender JID.
- msgid: The message id.
- type: The message type.
- time: The unix time when send message notification.
- onMessageReceivedServer:
- phone: The user phone number including the country code.
- from: The sender phone number.
- from: The sender JID.
- msgid: The message id.
- type: The message type.
- time: The unix time when send message notification.
Expand All @@ -214,36 +216,36 @@ Available events and arguments
- msgid: The message id.
- onPresence:
- phone: The user phone number including the country code.
- from: The sender phone number.
- from: The sender JID.
- type: The presence type.
- onSendMessageReceived:
- phone: The user phone number including the country code.
- time: The unix time when send message notification.
- from: The sender phone number.
- from: The sender JID.
- onSendPong:
- phone: The user phone number including the country code.
- msgid: The message id.
- onSendPresence:
- phone: The user phone number including the country code.
- type: Presence type.
- name: User name.
- name: User nickname.
- onSendStatusUpdate:
- phone: The user phone number including the country code.
- msg: The text message status.
- msg: The status message.
- onUploadFile:
- phone: The user phone number including the country code.
- name: The name.
- url: The remote url on WhatsApp servers.
- name: The filename.
- url: The remote url on WhatsApp servers (note: this is NOT the URL to download the file, only used for sending message).
- onUploadFileFailed:
- phone: The user phone number including the country code.
- name: The name.
- name: The filename.



How to binds a callback to a event
How to bind a callback to an event
==================================

# Events functions declarations
# Event handler declaration
```php
function MyFunction_onConnect($phone, $socket) {
print("$socket\n");
Expand All @@ -253,11 +255,11 @@ function MyFunction_onConnect($phone, $socket) {
```php
require 'whatsprot.class.php';
```
# Create an instance of WhastPort.
# Create an instance of WhastProt.
```php
$w = new WhatsProt($userPhone, $userIdentity, $userName, $debug);
```
# Binds a callback to a event
# Bind a callback to an event
```php
# $w->eventManager()->bind((string) $event, (string) $callback);
$w->eventManager()->bind('onConnect', 'MyFunction_onConnect');
Expand All @@ -266,8 +268,8 @@ $w->eventManager()->bind('onConnect', 'MyFunction_onConnect');
```php
$w->connect();
```
# Now Login function sends Nickname and (Available) Presence.
# Login to WhatsApp
```php
$w->login();
$w->loginWithPassword($password);
```
[...]

1 comment on commit 44a804f

@shirioko
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Wait, what? That's not README.md o_O

MOAR COFEH!

Please sign in to comment.