服务端发送消息 > Nodejs
 

服务器发送消息

REST Host

杭州: rest-hangzhou.goeasy.io
新加坡: rest-singapore.goeasy.io

RESTful API

URL:

 http(s)://<REST Host>/publish

什么是REST Host?

Method:

 Post

参数:

名称 必要 描述
appkey 您的appkey
channel channel
content 您要发送的消息内容

返回值:

 {
     "code" : 200,
     "content" : "OK"
 }

返回值的详细说明,请参考附录A

NodeJS

  var http = require('http');

  var appkey = 'Your appkey';
  var channel = 'my_channel';
  var content = 'Hello, GoEasy!';

  var queryParams = 'appkey='+appkey+'&channel='+channel+'&content='+content;

  var options = {
    hostname: '<REST Host>',
    path: '/publish',
    method: 'POST',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded'
    }
  };

  var req = http.request(options, (res) => {
    res.setEncoding('utf8');
    res.on('data', (result) => {
      console.log(`响应结果: ${result}`);
    });
  });

  req.on('error', (e) => {
    console.error(e);
  });

  req.write(queryParams);
  req.end();

什么是REST Host?

其他语言从服务端发送消息

C#
Java
NodeJs
PHP
Python
Ruby
其他语言调用Rest-API

results matching ""

    No results matching ""