-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
14 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,6 +56,8 @@ WhatsApp mobile app authentication may be achived by using [control panel](https | |
|
||
## Examples | ||
|
||
Please do not use 'phoneNumber' parameter when calling methods. It is deprecated. Examples below are based on 'chatId' paramemeter | ||
|
||
### Send WhatsApp message | ||
|
||
Use common javascript | ||
|
@@ -68,7 +70,7 @@ const restAPI = whatsAppClient.restAPI({ | |
apiTokenInstance: "YOUR_API_TOKEN_INSTANCE", | ||
}); | ||
|
||
restAPI.message.sendMessage(null, 79999999999, "hello world").then((data) => { | ||
restAPI.message.sendMessage("[email protected]", null , "hello world").then((data) => { | ||
console.log(data); | ||
}); | ||
``` | ||
|
@@ -83,7 +85,7 @@ or use browser js script | |
apiTokenInstance: "YOUR_API_TOKEN_INSTANCE", | ||
}); | ||
restAPI.message | ||
.sendMessage(null, 79999999999, "hello world") | ||
.sendMessage("[email protected]", null, "hello world") | ||
.then((data) => { | ||
console.log(data); | ||
}) | ||
|
@@ -104,8 +106,8 @@ import whatsAppClient from "@green-api/whatsapp-api-client"; | |
apiTokenInstance: "YOUR_API_TOKEN_INSTANCE", | ||
}); | ||
const response = await restAPI.message.sendMessage( | ||
"[email protected]", | ||
null, | ||
79999999999, | ||
"hello world" | ||
); | ||
})(); | ||
|
@@ -171,8 +173,8 @@ import whatsAppClient from "@green-api/whatsapp-api-client"; | |
apiTokenInstance: "YOUR_API_TOKEN_INSTANCE", | ||
}); | ||
const response = await restAPI.file.sendFileByUrl( | ||
"[email protected]", | ||
null, | ||
79999999999, | ||
"https://avatars.mds.yandex.net/get-pdb/477388/77f64197-87d2-42cf-9305-14f49c65f1da/s375", | ||
"horse.png", | ||
"horse" | ||
|
@@ -218,8 +220,8 @@ import bodyParser from "body-parser"; | |
}); | ||
// Send test message that triggers webhook | ||
const response = await restAPI.message.sendMessage( | ||
"[email protected]", | ||
null, | ||
79999999999, | ||
"hello world" | ||
); | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,6 +47,8 @@ import * as whatsAppClient from "@green-api/whatsapp-api-client"; | |
|
||
## Примеры | ||
|
||
Не испольуйте параметр 'phoneNumber' при вызове методов. Он устарел. Примеры ниже используют параметр 'chatId' | ||
|
||
### Отправка сообщения на номер WhatsApp | ||
Используя common js | ||
``` js | ||
|
@@ -57,7 +59,7 @@ const restAPI = whatsAppClient.restAPI(({ | |
apiTokenInstance: YOUR_API_TOKEN_INSTANCE | ||
})) | ||
|
||
restAPI.message.sendMessage(null, 79999999999, "hello world") | ||
restAPI.message.sendMessage("[email protected]", null, "hello world") | ||
.then((data) => { | ||
console.log(data); | ||
}) ; | ||
|
@@ -71,7 +73,7 @@ restAPI.message.sendMessage(null, 79999999999, "hello world") | |
idInstance: "YOUR_ID_INSTANCE", | ||
apiTokenInstance: "YOUR_API_TOKEN_INSTANCE" | ||
})) | ||
restAPI.message.sendMessage(null, 79999999999, "hello world") | ||
restAPI.message.sendMessage("[email protected]", null, "hello world") | ||
.then((data) => { | ||
console.log(data); | ||
}).catch((reason) =>{ | ||
|
@@ -89,7 +91,7 @@ import whatsAppClient from '@green-api/whatsapp-api-client' | |
idInstance: YOUR_ID_INSTANCE, | ||
apiTokenInstance: YOUR_API_TOKEN_INSTANCE | ||
})) | ||
const response = await restAPI.message.sendMessage(null, 79999999999, "hello world"); | ||
const response = await restAPI.message.sendMessage("[email protected]", null, "hello world"); | ||
})(); | ||
``` | ||
|
||
|
@@ -150,7 +152,7 @@ import whatsAppClient from '@green-api/whatsapp-api-client' | |
idInstance: YOUR_ID_INSTANCE, | ||
apiTokenInstance: YOUR_API_TOKEN_INSTANCE | ||
})) | ||
const response = await restAPI.file.sendFileByUrl(null, 79999999999, 'https://avatars.mds.yandex.net/get-pdb/477388/77f64197-87d2-42cf-9305-14f49c65f1da/s375', 'horse.png', 'horse'); | ||
const response = await restAPI.file.sendFileByUrl("[email protected]", null, 'https://avatars.mds.yandex.net/get-pdb/477388/77f64197-87d2-42cf-9305-14f49c65f1da/s375', 'horse.png', 'horse'); | ||
})(); | ||
``` | ||
|
||
|
@@ -190,7 +192,7 @@ import bodyParser from 'body-parser'; | |
apiTokenInstance: MY_API_TOKEN_INSTANCE | ||
})); | ||
// Отправляем тестовое сообщение, для того чтобы сработали события вебхуков | ||
const response = await restAPI.message.sendMessage(null, 79999999999, "hello world"); | ||
const response = await restAPI.message.sendMessage("[email protected]", null, "hello world"); | ||
|
||
}); | ||
} catch (error) { | ||
|