|
@@ -0,0 +1,270 @@
|
|
|
+package main
|
|
|
+
|
|
|
+import (
|
|
|
+ "encoding/json"
|
|
|
+ "fmt"
|
|
|
+ "io/ioutil"
|
|
|
+ "net/http"
|
|
|
+ "strings"
|
|
|
+)
|
|
|
+
|
|
|
+func main() {
|
|
|
+ // token, err := login()
|
|
|
+ // if err != nil {
|
|
|
+ // fmt.Println(err)
|
|
|
+ // return
|
|
|
+ // }
|
|
|
+ // fmt.Println(token)
|
|
|
+ token := "I2QhtXO_jL7-r-qfu3c93HhiUrY_qSnCw6ZaMx9ImD2IL"
|
|
|
+ getProduct(token)
|
|
|
+ //getLiquidFlow(token)
|
|
|
+ //getLNGFlow(token)
|
|
|
+}
|
|
|
+
|
|
|
+// 获取token登录凭证
|
|
|
+func login()(token string, err error){
|
|
|
+
|
|
|
+ url := "https://api-lng.kpler.com/v1/login"
|
|
|
+ method := "POST"
|
|
|
+
|
|
|
+ payload := strings.NewReader(`{
|
|
|
+ "email": "lizhan.edri@sinopec.com",
|
|
|
+ "password": "edri2024"
|
|
|
+}`)
|
|
|
+
|
|
|
+ client := &http.Client {
|
|
|
+ }
|
|
|
+ req, err := http.NewRequest(method, url, payload)
|
|
|
+
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println(err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ req.Header.Add("Content-Type", "application/json")
|
|
|
+
|
|
|
+ res, err := client.Do(req)
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println(err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ defer res.Body.Close()
|
|
|
+
|
|
|
+ body, err := ioutil.ReadAll(res.Body)
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println(err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ fmt.Println(string(body))
|
|
|
+ //bodyStr := `{"token":"lfl883KgRgwsBg_yuHjv05vr6voK2ac8ju47jiUoR8ccs","user":{"accounts":["coal","lpg","lng","oil","cpp","merge","liquids"]}}`
|
|
|
+ //解析body
|
|
|
+ var result map[string]interface{}
|
|
|
+ err = json.Unmarshal(body, &result)
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println(err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ token = result["token"].(string)
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+func getProduct(token string) {
|
|
|
+ url := "https://api.kpler.com/v1/products?size=100"
|
|
|
+ method := "GET"
|
|
|
+
|
|
|
+ client := &http.Client {
|
|
|
+ }
|
|
|
+ req, err := http.NewRequest(method, url, nil)
|
|
|
+
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println(err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ req.Header.Add("Content-Type", "application/json")
|
|
|
+ req.Header.Add("Authorization", token)
|
|
|
+ res, err := client.Do(req)
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println(err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ defer res.Body.Close()
|
|
|
+
|
|
|
+ body, err := ioutil.ReadAll(res.Body)
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println(err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ fmt.Println(string(body))
|
|
|
+ //bodystr := "Id (Product);Name;Type (Product);Family;Family Id;Group;Group Id;Product;Product Id;Grade;Grade Id;Density (Product);Density Unit;Energy Density;Energy Density Unit;Expansion Ratio
|
|
|
+// 2952;CPC Russia;grade;Dirty;1398;Crude/Co;1370;Crude;1368;CPC Russia;2952;805.0;kg/cm;26948.236;MJ/cm;1.0
|
|
|
+// 2953;CPC Kazakhstan;grade;Dirty;1398;Crude/Co;1370;Crude;1368;CPC Kazakhstan;2953;805.0;kg/cm;26948.236;MJ/cm;1.0
|
|
|
+// 1360;CPC;grade;Dirty;1398;Crude/Co;1370;Crude;1368;CPC;1360;805.0;kg/cm;26948.236;MJ/cm;1.0"
|
|
|
+}
|
|
|
+
|
|
|
+func getZone(token string) {
|
|
|
+ url := "https://api.kpler.com/v1/zones?ancestorName=Baltic%20Sea&descendantType=port"
|
|
|
+ method := "GET"
|
|
|
+
|
|
|
+ client := &http.Client {
|
|
|
+ }
|
|
|
+ req, err := http.NewRequest(method, url, nil)
|
|
|
+
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println(err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ req.Header.Add("Content-Type", "application/json")
|
|
|
+ req.Header.Add("Authorization", token)
|
|
|
+ res, err := client.Do(req)
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println(err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ defer res.Body.Close()
|
|
|
+
|
|
|
+ body, err := ioutil.ReadAll(res.Body)
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println(err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ fmt.Println(string(body))
|
|
|
+// bodyStr := `Ancestor Id;Ancestor Name;Ancestor Type;Descendant Id;Descendant Name;Descendant Type
|
|
|
+// 87;Baltic Sea;gulf;1669;Kokkola;port
|
|
|
+// 87;Baltic Sea;gulf;1264;Stigsnaes;port
|
|
|
+// 87;Baltic Sea;gulf;110162;Uddevalla;port
|
|
|
+// 87;Baltic Sea;gulf;112012;Harnosand;port
|
|
|
+// 87;Baltic Sea;gulf;112945;Energihamnen;port
|
|
|
+// 87;Baltic Sea;gulf;112957;Falkenberg;port
|
|
|
+// 87;Baltic Sea;gulf;110567;Jakobstad;port
|
|
|
+// 87;Baltic Sea;gulf;112930;Sandefjord;port
|
|
|
+// 87;Baltic Sea;gulf;113141;Korsor;port
|
|
|
+// 87;Baltic Sea;gulf;3603;Inkoo;port
|
|
|
+// 87;Baltic Sea;gulf;112946;Skeppsbron;port
|
|
|
+// 87;Baltic Sea;gulf;112943;Vartahamnen;port
|
|
|
+// 87;Baltic Sea;gulf;112936;Solvesborg;port
|
|
|
+// 87;Baltic Sea;gulf;3388;Pori;port
|
|
|
+// 87;Baltic Sea;gulf;112944;Stadsgarden;port
|
|
|
+// 87;Baltic Sea;gulf;1697;Nacka;port
|
|
|
+// 87;Baltic Sea;gulf;107545;Grenaa;port
|
|
|
+// 87;Baltic Sea;gulf;107515;Wismar;port
|
|
|
+// 87;Baltic Sea;gulf;2604;Vysotsk;port
|
|
|
+// 87;Baltic Sea;gulf;112752;Stockholm;port
|
|
|
+// 87;Baltic Sea;gulf;113125;Monsteras;port
|
|
|
+// 87;Baltic Sea;gulf;113161;Hirtshals;port
|
|
|
+// 87;Baltic Sea;gulf;116132;Trelleborg;port
|
|
|
+// 87;Baltic Sea;gulf;1400;Lindø Industrial Park;port
|
|
|
+// 87;Baltic Sea;gulf;112013;Sandarne;port
|
|
|
+// 87;Baltic Sea;gulf;112011;Ornskoldsvik;port
|
|
|
+// 87;Baltic Sea;gulf;107089;Landskrona;port
|
|
|
+// 87;Baltic Sea;gulf;4689;Koping;port
|
|
|
+// 87;Baltic Sea;gulf;112745;Kaskinen;port
|
|
|
+// 87;Baltic Sea;gulf;112210;Vasteras;port
|
|
|
+// 87;Baltic Sea;gulf;112165;Kalmar;port
|
|
|
+// 87;Baltic Sea;gulf;112167;Paljassaare;port
|
|
|
+// 87;Baltic Sea;gulf;112152;Forby;port
|
|
|
+// 87;Baltic Sea;gulf;112194;Port of Koge;port
|
|
|
+// 87;Baltic Sea;gulf;112202;Lomonosov;port
|
|
|
+// 87;Baltic Sea;gulf;3423;Aarhus;port
|
|
|
+// 87;Baltic Sea;gulf;107591;Koloniya;port
|
|
|
+// 87;Baltic Sea;gulf;6812;Nyborg;port
|
|
|
+// 87;Baltic Sea;gulf;113842;Halden;port
|
|
|
+// 87;Baltic Sea;gulf;1027;Porvoo;port
|
|
|
+// 87;Baltic Sea;gulf;116201;Nykobing Falster;port
|
|
|
+// 87;Baltic Sea;gulf;116181;Ostrand;port
|
|
|
+// 87;Baltic Sea;gulf;113276;Karlsborg;port
|
|
|
+// 87;Baltic Sea;gulf;1651;Gdynia;port
|
|
|
+// 87;Baltic Sea;gulf;1102;Naantali;port
|
|
|
+// 87;Baltic Sea;gulf;112137;Drammen;port
|
|
|
+// 87;Baltic Sea;gulf;1165;Klaipeda;port
|
|
|
+// 87;Baltic Sea;gulf;6167;Hamina;port
|
|
|
+// 87;Baltic Sea;gulf;113292;Vastervik;port
|
|
|
+// 87;Baltic Sea;gulf;116242;Saetre;port
|
|
|
+// 87;Baltic Sea;gulf;116535;Frederikshavn;port
|
|
|
+// 87;Baltic Sea;gulf;1444;Aabenraa;port
|
|
|
+// 87;Baltic Sea;gulf;3725;Apatyth FSU;port
|
|
|
+// 87;Baltic Sea;gulf;1271;Primorsk;port
|
|
|
+// 87;Baltic Sea;gulf;1465;Karlshamn;port
|
|
|
+// 87;Baltic Sea;gulf;1399;Paldiski;port
|
|
|
+// 87;Baltic Sea;gulf;1684;Kemi;port
|
|
|
+// 87;Baltic Sea;gulf;1717;Vaasa;port
|
|
|
+// 87;Baltic Sea;gulf;110127;Nordjyllandsvaerket;port
|
|
|
+// 87;Baltic Sea;gulf;3467;Kiel;port
|
|
|
+// 87;Baltic Sea;gulf;4239;Kaliningrad;port
|
|
|
+// 87;Baltic Sea;gulf;3805;Loudden;port
|
|
|
+// 87;Baltic Sea;gulf;1404;Provestenen;port
|
|
|
+// 87;Baltic Sea;gulf;3403;Södertälje;port
|
|
|
+// 87;Baltic Sea;gulf;2002;Liepaja;port
|
|
|
+// 87;Baltic Sea;gulf;3389;Mussalo;port
|
|
|
+// 87;Baltic Sea;gulf;3407;Sundsvall;port
|
|
|
+// 87;Baltic Sea;gulf;3392;Halmstad;port
|
|
|
+// 87;Baltic Sea;gulf;2215;Raahe;port
|
|
|
+// 87;Baltic Sea;gulf;1334;Riga Harbour;port
|
|
|
+// 87;Baltic Sea;gulf;3381;Miiduranna;port
|
|
|
+// 87;Baltic Sea;gulf;1166;Gdansk;port
|
|
|
+// 87;Baltic Sea;gulf;107049;Oskarshamn;port
|
|
|
+// 87;Baltic Sea;gulf;3413;Holmsund;port
|
|
|
+// 87;Baltic Sea;gulf;3391;Rauma;port
|
|
|
+// 87;Baltic Sea;gulf;3393;Helsingborg;port
|
|
|
+// 87;Baltic Sea;gulf;3438;Sjursoya;port
|
|
|
+// 87;Baltic Sea;gulf;1553;Rostock;port
|
|
|
+// 87;Baltic Sea;gulf;1155;Sillamäe;port
|
|
|
+// 87;Baltic Sea;gulf;3664;Szczecin;port
|
|
|
+// 87;Baltic Sea;gulf;1362;Malmo;port
|
|
|
+// 87;Baltic Sea;gulf;1104;Nynashamn;port
|
|
|
+// 87;Baltic Sea;gulf;1158;Butinge;port
|
|
|
+// 87;Baltic Sea;gulf;1700;Oulu;port
|
|
|
+// 87;Baltic Sea;gulf;5454;Slagen;port
|
|
|
+// 87;Baltic Sea;gulf;1477;Norrkoping;port
|
|
|
+// 87;Baltic Sea;gulf;6722;Kunda Bay;port
|
|
|
+// 87;Baltic Sea;gulf;6761;Pitea;port
|
|
|
+// 87;Baltic Sea;gulf;1020;Swinoujscie Area;port
|
|
|
+// 87;Baltic Sea;gulf;3426;Aalborg;port
|
|
|
+// 87;Baltic Sea;gulf;105360;Visby;port
|
|
|
+// 87;Baltic Sea;gulf;3151;Gavle;port
|
|
|
+// 87;Baltic Sea;gulf;1445;Oxelosund;port
|
|
|
+// 87;Baltic Sea;gulf;3411;Ronnskar;port
|
|
|
+// 87;Baltic Sea;gulf;113011;Husum;port
|
|
|
+// 87;Baltic Sea;gulf;2008;Lulea;port
|
|
|
+// 87;Baltic Sea;gulf;107538;Varberg;port
|
|
|
+// 87;Baltic Sea;gulf;107537;Orrskar;port
|
|
|
+// 87;Baltic Sea;gulf;4690;Uusikaupunki Port;port
|
|
|
+// 87;Baltic Sea;gulf;110094;Studstrup;port
|
|
|
+// 87;Baltic Sea;gulf;6723;Helsinki;port
|
|
|
+// 87;Baltic Sea;gulf;1028;St Petersburg;port
|
|
|
+// 87;Baltic Sea;gulf;107467;Valko;port
|
|
|
+// 87;Baltic Sea;gulf;116671;Skoghall;port
|
|
|
+// 87;Baltic Sea;gulf;2464;Ventspils;port
|
|
|
+// 87;Baltic Sea;gulf;113860;Soby Havn;port
|
|
|
+// 87;Baltic Sea;gulf;3382;Kopli;port
|
|
|
+// 87;Baltic Sea;gulf;1156;Muuga Harbour;port
|
|
|
+// 87;Baltic Sea;gulf;2601;Ust Luga;port`
|
|
|
+}
|
|
|
+
|
|
|
+func getFlow(token string) {
|
|
|
+ url := "https://api.kpler.com/v1/flows?unit=kb&flowDirection=export&granularity=monthly&toZones=China&products=CPC%20Russia,Eastern%20Russia%20Crude,Western%20Russia%20Crude&split=Destination%20Countries&withIntraRegion=true"
|
|
|
+ method := "GET"
|
|
|
+
|
|
|
+ client := &http.Client {
|
|
|
+ }
|
|
|
+ req, err := http.NewRequest(method, url, nil)
|
|
|
+
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println(err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ req.Header.Add("Authorization", token)
|
|
|
+
|
|
|
+ res, err := client.Do(req)
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println(err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ defer res.Body.Close()
|
|
|
+
|
|
|
+ body, err := ioutil.ReadAll(res.Body)
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println(err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ fmt.Println(string(body))
|
|
|
+}
|