Skip to content

Go library for Adobe's AMF, with remoting support

Notifications You must be signed in to change notification settings

kumakichi/goamf

Repository files navigation

About

https://godoc.org/github.com/kumakichi/goamf?status.png

This repository is based on amf.go written by paulhodge, and I add and modify codes according to PyAMF.

Currently, support AMF3 only.

Normally, you need only NewRequest, and maybe ParseRespBody. For more detail infomation, read the doc.

Example

package main

import (
        "fmt"
        "io"
        "io/ioutil"
        "log"
        "net/http"

        "github.com/kumakichi/goamf"
)

const (
        URL = "http://aqi.zjemc.org.cn/aqi/messagebroker/amf"
)

func main() {
        //You can send mutiple requests per time, like this:
        //
        //reader, header, err := amf.NewRequest([]interface{}{
        //      []interface{}{"getAreaDayReprotData", "GisCommonDataUtil"},
        //      []interface{}{"getAreaRealTimeReportData", "GisCommonDataUtil"},
        //})

        //Single request
        reader, header, err := amf.NewRequest("getAreaDayReprotData", "GisCommonDataUtil")
        checkError(err)

        b := requestWithHeader(reader, header)

        body, err := amf.ParseRespBody(b)
        checkError(err)
        fmt.Printf("Body size: %d,%v\n", len(body), body)
}

func checkError(err error) {
        if err != nil {
                log.Fatal(err)
        }
}

func requestWithHeader(reader io.Reader, header http.Header) []byte {
        client := &http.Client{}
        req, err := http.NewRequest("POST", URL, reader)
        checkError(err)

        req.Header = header
        resp, err := client.Do(req)
        checkError(err)

        defer resp.Body.Close()

        b, err := ioutil.ReadAll(resp.Body)
        checkError(err)

        return b
}

About

Go library for Adobe's AMF, with remoting support

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published