获取站点预报数据

简要描述:

获取站点预报数据

请求方式:

POST

请求头:

签名计算过程较为复杂,计算过程可以参考请求签名说明文档

请求参数:

                       
//using System.IO;
//using System.Text;
//using System.Net;
//using System.Net.Security;
//using System.Security.Cryptography.X509Certificates;

private const String host = "http://service-tide.nmdis.org.cn:8080/api/v1/CoreData/GetPortTideData";
private const String method = "POST";
private const String appid = "你自己的appid";
private const String appsecret = "你自己的appsecret";

static void Main(string[] args)
{
    String querys = "SiteCode=S003&Date=2017-05-01";
    String bodys = "";
    String url = host;
    HttpWebRequest httpRequest = null;
    HttpWebResponse httpResponse = null;

    if (0 < querys.Length)
    {
        url = url + "?" + querys;
    }

    if (host.Contains("https://"))
    {
        ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
        httpRequest = (HttpWebRequest)WebRequest.CreateDefault(new Uri(url));
    }
    else
    {
        httpRequest = (HttpWebRequest)WebRequest.Create(url);
    }
    httpRequest.Method = method;
    httpRequest.Headers.Add("appid", appid);
    httpRequest.Headers.Add("appsecret", appsecret);
    if (0 < bodys.Length)
    {
        byte[] data = Encoding.UTF8.GetBytes(bodys);
        using (Stream stream = httpRequest.GetRequestStream())
        {
            stream.Write(data, 0, data.Length);
        }
    }
    try
    {
        httpResponse = (HttpWebResponse)httpRequest.GetResponse();
    }
    catch (WebException ex)
    {
        httpResponse = (HttpWebResponse)ex.Response;
    }

    Console.WriteLine(httpResponse.StatusCode);
    Console.WriteLine(httpResponse.Method);
    Console.WriteLine(httpResponse.Headers);
    Stream st = httpResponse.GetResponseStream();
    StreamReader reader = new StreamReader(st, Encoding.GetEncoding("utf-8"));
    Console.WriteLine(reader.ReadToEnd());
    Console.WriteLine("\n");

}

public static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
{
    return true;
}
                   
                    
public static void main(String[] args) {
	String host = "http://service-tide.nmdis.org.cn:8080/api/v1";
	String path = "/CoreData/GetPortTideData";
	String method = "POST";
	String appid = "你自己的Appid";
    String appsecret = "你自己的appsecret";
	Map <string,String> headers = new HashMap <string,String>();
	//最后在header中的格式(中间是英文空格)为Authorization:APPCODE 83359fd73fe94948385f570e3c139105
	headers.put("appid", appid);
    headers.put("appsecret", appsecret);
	Map <string,String> querys = new HashMap <string,String>();
	querys.put("SiteCode", "S003");
	querys.put("Date", "2017-05-01");
	Map <string,String> bodys = new HashMap <string,String>();
	try {
		HttpResponse response = HttpUtils.doPost(host, path, method, headers, querys, bodys);
		System.out.println(response.toString());
		//获取response的body
		//System.out.println(EntityUtils.toString(response.getEntity()));
	} catch (Exception e) {
		e.printStackTrace();
	}
}
                        
<?php
$host = "http://service-tide.nmdis.org.cn:8080/api/v1/CoreData/GetPortTideData";
$method = "POST";
$appid = "你自己的appid";
$appsecret = "你自己的appsecret";
$headers = array();
array_push($headers, "appid" . $appid);
array_push($headers, "appsecret" . $appsecret);
$querys = "SiteCode=S003&Date=2017-05-01";
$bodys = "";
$url = $host . "?" . $querys;

$curl = curl_init();
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_FAILONERROR, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, true);
if (1 == strpos("$".$host, "https://")){
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
}
var_dump(curl_exec($curl));
?>
      
						
                       
import urllib, urllib2, sys

host = 'http://service-tide.nmdis.org.cn:8080/api/v1/CoreData/GetPortTideData'
method = 'POST'
appid = '你自己的appid'
appsecret = '你自己的appsecret'
querys = 'SiteCode=S003&Date=2017-05-01'
bodys = {}
url = host + '?' + querys

request = urllib2.Request(url)
request.add_header('appid', appid)
request.add_header('appsecret', appsecret)
response = urllib2.urlopen(request)
content = response.read()
if (content):
print(content)
                        
                        

参数示例:

{{ paramsTab1_Code }}

返回示例:

正确时返回:

{{ backTab1_Right }}

错误时返回:

{{ backTab1_Error }}

返回参数说明:

潮汐:

旋转流:

往复流:

错误代码说明:

获取站点信息

简要描述:

获取站点信息

请求方式:

POST

请求头:

签名计算过程较为复杂,计算过程可以参考请求签名说明文档

请求参数:

参数示例:

{{ paramsTab2_Code }}
                        
//using System.IO;
//using System.Text;
//using System.Net;
//using System.Net.Security;
//using System.Security.Cryptography.X509Certificates;

private const String host = "http://service-tide.nmdis.org.cn:8080/api/v1/CoreData/GetPortList";
private const String method = "POST";
private const String appid = "你自己的appid";
private const String appsecret = "你自己的appsecret";

static void Main(string[] args)
{
    String querys = "appid=" + appid;
    String bodys = "";
    String url = host;
    HttpWebRequest httpRequest = null;
    HttpWebResponse httpResponse = null;

    if (0 < querys.Length)
    {
        url = url + "?" + querys;
    }

    if (host.Contains("https://"))
    {
        ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
        httpRequest = (HttpWebRequest)WebRequest.CreateDefault(new Uri(url));
    }
    else
    {
        httpRequest = (HttpWebRequest)WebRequest.Create(url);
    }
    httpRequest.Method = method;
    httpRequest.Headers.Add("appid", appid);
    httpRequest.Headers.Add("appsecret", appsecret);
    if (0 < bodys.Length)
    {
        byte[] data = Encoding.UTF8.GetBytes(bodys);
        using (Stream stream = httpRequest.GetRequestStream())
        {
            stream.Write(data, 0, data.Length);
        }
    }
    try
    {
        httpResponse = (HttpWebResponse)httpRequest.GetResponse();
    }
    catch (WebException ex)
    {
        httpResponse = (HttpWebResponse)ex.Response;
    }

    Console.WriteLine(httpResponse.StatusCode);
    Console.WriteLine(httpResponse.Method);
    Console.WriteLine(httpResponse.Headers);
    Stream st = httpResponse.GetResponseStream();
    StreamReader reader = new StreamReader(st, Encoding.GetEncoding("utf-8"));
    Console.WriteLine(reader.ReadToEnd());
    Console.WriteLine("\n");

}

public static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
{
    return true;
}
                  
                    
public static void main(String[] args) {
	String host = "http://service-tide.nmdis.org.cn:8080/api/v1";
	String path = "/CoreData/GetPortList";
	String method = "POST";
	String appid = "你自己的Appid";
    String appsecret = "你自己的appsecret";
	Map <string,String> headers = new HashMap <string,String>();
	//最后在header中的格式(中间是英文空格)为Authorization:APPCODE 83359fd73fe94948385f570e3c139105
	headers.put("appid", appid);
    headers.put("appsecret", appsecret);
	Map <string,String> querys = new HashMap <string,String>();
	querys.put("appid", appid);
	Map <string,String> bodys = new HashMap <string,String>();
	try {
		HttpResponse response = HttpUtils.doPost(host, path, method, headers, querys, bodys);
		System.out.println(response.toString());
		//获取response的body
		//System.out.println(EntityUtils.toString(response.getEntity()));
	} catch (Exception e) {
		e.printStackTrace();
	}
}
                       
<?php
$host = "http://service-tide.nmdis.org.cn:8080/api/v1/CoreData/GetPortList";
$method = "POST";
$appid = "你自己的appid";
$appsecret = "你自己的appsecret";
$headers = array();
array_push($headers, "appid" . $appid);
array_push($headers, "appsecret" . $appsecret);
$querys = "appid=" .$appid;
$bodys = "";
$url = $host . "?" . $querys;

$curl = curl_init();
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_FAILONERROR, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HEADER, true);
if (1 == strpos("$".$host, "https://")){
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
}
var_dump(curl_exec($curl));
?>
      
						
                       
import urllib, urllib2, sys

host = 'http://service-tide.nmdis.org.cn:8080/api/v1/CoreData/GetPortList'
method = 'POST'
appid = '你自己的appid'
appsecret = '你自己的appsecret'
querys = 'appid=' + appid
bodys = {}
url = host + '?' + querys

request = urllib2.Request(url)
request.add_header('appid', appid)
request.add_header('appsecret', appsecret)
response = urllib2.urlopen(request)
content = response.read()
if (content):
print(content)
                        
                        

返回示例:

正确时返回:

{{ backTab2_Right }}

错误时返回:

{{ backTab2_Error }}

返回参数说明:

错误代码说明: