TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Ivan Climov
1.1k
692
22.4k
Viber-API. I get the error message "Bad receiver ID".
Jun 27 2019 10:30 AM
Created an application.
I try to get information on the "bot".
I get the following information:
2. I try to send a message to user "members.1".
I use:
- language - C#;
- WinForm;
- recommendations - https://developers.viber.com/docs/api/rest-bot-api/#send-message;
- for "Receiver": "01234567890A =" I use "id" from item.1 -> picture 4 -> id
I use the code.
class
ViberMessage
{
public
string
Receiver {
get
;
set
; }
///
/// Minimum API version required by clients for this message (default 1)
///
public
int
Min_api_version {
get
;
set
; } = 1;
public
ViberSender Sender {
get
;
set
; }
public
string
Tracking_data {
get
;
set
; }
public
string
Type {
get
;
set
; } =
"text"
;
public
string
Text {
get
;
set
; }
}
public
class
ViberSender
{
public
string
Name {
get
;
set
; }
public
string
Avatar {
get
;
set
; }
}
///
/// Send a message. Member Account.
///
///
///
private
void
bt_SendMessMemb_Click(
object
sender, EventArgs e)
{
string
json = FillMember_2();
Encoding utf = Encoding.UTF8;
byte
[] jsonUTF = utf.GetBytes(json);
string
jsonUTFstr = utf.GetString(jsonUTF);
MessageWork messageWork =
new
MessageWork();
messageWork.ViberCall(jsonUTFstr);
}
public
string
FillMember_2()
{
string
json =
""
;
var msg =
new
ViberMessage
{
Receiver =
"?u7L???+wyD/?????????=="
,
// text conditionally hidden
Min_api_version = 1,
Sender =
new
ViberSender
{
Name =
"?????"
,
Avatar =
""
},
Tracking_data =
"tracking data"
,
Type =
"text"
,
Text =
"Test message - 1"
};
json = JsonConvert.SerializeObject(msg);
return
json;
}
class
MessageWork
{
public
void
ViberCall(
string
json)
{
var request = (HttpWebRequest)WebRequest.Create(
"https://chatapi.viber.com/pa/send_message"
);
request.ContentType =
"application/json"
;
request.Method =
"POST"
;
request.Headers.Add(
"X-Viber-Auth-Token"
,
"49c9a7b9a9e7d096-XXXXXXXXXXXX-XXXXXXXXX"
);
// text conditionally hidden
using
(var streamWriter =
new
StreamWriter(request.GetRequestStream()))
{
streamWriter.Write(jsonN);
streamWriter.Flush();
}
string
resultStr;
var response = (HttpWebResponse)request.GetResponse();
using
(var streamReader =
new
StreamReader(response.GetResponseStream()))
{
var result = streamReader.ReadToEnd();
resultStr = result.ToString();
}
jsonN = jsonN +
"/r/n "
+ resultStr;
}
}
In the line "jsonN = jsonN +" \ r \ n "+ resultStr; " I get
{"Receiver":"?u7L???+wyD/?????????==", // text conditionally hidden
"Min_api_version":1,
"Sender":{"Name":"?????","Avatar":""},
"Tracking_data":"tracking data","Type":"text",
"Text":"???????? ????????? - 1"}
{"status":999,
"status_message":"Bad receiver ID",
"message_token":5324763260407665007,
"chat_hostname":"SN-CHAT-05_"}
Question.
1. Why do I get the error "status_message": "Bad receiver ID"?
2. How to extinguish this error?
Reply
Answers (
0
)
payment gateway integration Unity 3D game application
reading xml document as attribute name and attirbute value