Tôi không thể nhận phản hồi từ GCM ngay cả khi tôi đang cung cấp khóa API máy chủ chính xác do google tạo.Lỗi trái phép GCM 401
Sự cố: Tôi muốn thực hiện thông báo đẩy bằng GCM từ ứng dụng buồm của tôi. tôi gửi bài dưới mã để "https://android.googleapis.com/gcm/send"
Code: 1
{
"headers":{
"Content-Type":"application/json",
"Authorization":"key=xxxxxxxxxxxxxxxxxxxx"
},
"notification":{
"title":"Hello Notify",
"text":"Notification By Sails"
},
"registration_ids":["xxxxxxxxxxxx","xxxxxxxxxxxx","xxxxxxxxxxxx"]
}
Mã số: 2
{
"headers":{
"Content-Type":"application/json",
"Authorization":"key=xxxxxxxxxxxxxxxxxxxx"
},
"body":{
"notification":{
"title":"Hello Notify",
"text":"Notification By Sails"
}
},
"registration_ids":["xxxxxxxxxxxx","xxxxxxxxxxxx","xxxxxxxxxxxx"]
}
tôi nhận được câu trả lời như sau.
"statusCode": 401,
"body": "<HTML>\n
<HEAD>\n<TITLE>Unauthorized</TITLE>\n</HEAD>\n
<BODY BGCOLOR=\"#FFFFFF\" TEXT=\"#000000\">\n
<H1>Unauthorized</H1>\n
<H2>Error 401</H2>\n
</BODY>\n
</HTML>\n",
bạn có thể cung cấp ví dụ làm việc không? – DebuggerCoder
Ví dụ ở đây phải phù hợp hơn với những gì bạn muốn đạt được: http://code.runnable.com/U4kVi8yKO58ptG0l/%5Bandroid-api%5D-gcm-send-using-node-js –
@DebuggerCoder curl -X POST - -header "Content-Type: application/json" - tiêu đề "Cấp phép: khóa = AIzaXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" "https://android.googleapis.com/gcm/send" --data-ascii '{"thông báo": {"nội dung ":" yyy "}," tới ":" XXXXXXXXXX: YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY-ZZZZZZZZZZZZZZZZZZZZ "} ' – TheWonderBird