Server Operations

REST Host

Hangzhou: rest-hangzhou.goeasy.io
Singapore: rest-singapore.goeasy.io

RESTful API

URL:

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

What is REST Host?

Method:

 Post

Parameters:

Name Required Description
appkey Yes Your app key
channel Yes Target channel name
content Yes The message you want to publish

Return:

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

For more detailed information of the return value, read the Appendix A.

PHP

$url = 'http(s)://<REST Host>/publish';  


$post_data = array("appkey"=>"BC-xxxxxxxxx","channel"=>$channel,"content"=>$channel);

echo php_ajax($url,$post_data);


function php_ajax($url, $post_data) {
  $postdata = http_build_query($post_data);
  $options = array(
    'http' => array(
      'method' => 'POST',
      'header' => 'Content-type:application/x-www-form-urlencoded',
      'content' => $postdata,
      'timeout' => 15 * 60 
    )
  );
  $context = stream_context_create($options);
  $result = file_get_contents($url, false, $context);

  return $result;
}

What is REST Host?

C#

string postDataStr = "appkey=BC-xxxxxxxxx&channel=demo_channel&content=Hello";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http(s)://<REST Host>/publish");
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded;charset=UTF-8";
request.ContentLength = Encoding.UTF8.GetByteCount(postDataStr);
Stream myRequestStream = request.GetRequestStream();
byte[] data = Encoding.UTF8.GetBytes(postDataStr);
myRequestStream.Write(data, 0, data.Length);

HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Stream myResponseStream = response.GetResponseStream();
StreamReader myStreamReader = new StreamReader(myResponseStream, Encoding.GetEncoding("utf-8"));
string retString = myStreamReader.ReadToEnd();
myStreamReader.Close();
myResponseStream.Close();

What is REST Host?

Python

appkey = "BC-xxxxxxxxx"
channel = "my_channel"
content = "Hello, GoEasy!"
data = {"appkey" : appkey, "channel" : channel, "content" : content}
url = "http(s)://<REST Host>/publish"
response = requests.post(url, data = data)

What is REST Host?

Ruby

require 'net/http'

class GoEasyClient
  def self.send(channel, content)
    Thread.new {
      Net::HTTP.post_form(URI("http(s)://<REST Host>/publish"),
       {appkey: "BC-xxxxxxxxx", channel: channel, content: content})
    }
  end
end

What is REST Host?

Java

Option 1. Manually download

goeasy-sdk.jar

Add dependency libraries:​ gson-2.3.1.jar, slf4j-api-1.7.2.jar

Option 2. Maven

​ Add goeasy repository to your pom.xml

<repositories>
    ...
    <repository>
        <id>goeasy</id>
        <name>goeasy</name>
        <url>
            http://maven.goeasy.io/content/repositories/releases/
        </url>
    </repository>
</repositories>

and then add dependency:

<dependencies>
    ...
    <dependency>
        <groupId>io.goeasy</groupId>
        <artifactId>goeasy-sdk</artifactId>
        <version>0.3.8</version>
    </dependency>
</dependencies>

What is REST Host?

results matching ""

    No results matching ""