C # Call the gold data API,
First of all, spit out the gold data API documentation http://help.jinshuju.net/articles/api-intro.html written very rough ah... anyway, I am not too clear
The form api is used as an example to show you only an address.https://jinshuju.net/api/v1/forms/ex27t2And then, if there is no more, you can guess it.ex27t2It should be changed, but what should I fill in...
Here, you should enter a value in your form. It seems that this value is only available in such places. I have not found this value in other places ..
In addition, it is useless to submit a consulting ticket. The reply message only replied, "we currently do not provide such technical support. If you have other questions, open a ticket. If you have any questions, please refer to our help center. Welcome to the official website of golden data (Golden data service No./jinshuju-service )."
Do it by yourself...
Okay, I don't want to talk about anything else. Just go to the code.
Public class JinShuJu {private static string Key = "9hh6fIbLOqDrgin4Q_r6X"; private static string Secret = "z3RSib8HeQBfau6zwRpRo "; /// <summary> /// obtain the form API /// </summary> /// <returns> </returns> public static string GetFromAPI () {string uri = "https://jinshuju.net/api/v1/forms/RsE5EC"; string result = string. empty; WebRequest request = WebRequest. create (new Uri (uri); request. credentials = GetCredentialCache (uri, Key, Secret); request. headers. add ("Authorization", GetAuthorization (Key, Secret); request. timeout = 2000; WebResponse response = request. getResponse (); Stream stream = response. getResponseStream (); StreamReader sr = new StreamReader (stream); result = sr. readToEnd (); sr. close (); stream. close (); return result ;} /// <summary> /// submit the data API /// </summary> /// <param name = "JSONData"> </param> /// <returns> </returns> public static string PostFromAPI (string JSONData) {string uri = "https://jinshuju.net/api/v1/forms/RsE5EC"; string result = string. empty; WebRequest request = WebRequest. create (new Uri (uri); request. credentials = GetCredentialCache (uri, Key, Secret); request. headers. add ("Authorization", GetAuthorization (Key, Secret); request. timeout = 2000; byte [] bytes = Encoding. UTF8.GetBytes (JSONData); request. method = "POST"; request. contentType = "application/json"; string paraUrlCoded = JSONData; byte [] payload; payload = System. text. encoding. UTF8.GetBytes (paraUrlCoded); request. contentLength = payload. length; Stream writer = request. getRequestStream (); writer. write (payload, 0, payload. length); writer. close (); WebResponse response = request. getResponse (); Stream stream = response. getResponseStream (); StreamReader sr = new StreamReader (stream); result = sr. readToEnd (); sr. close (); stream. close (); return result ;}# region # generate Http Basic Access Credential # private static CredentialCache GetCredentialCache (string uri, string username, string password) {string authorization = string. format ("{0 }:{ 1}", username, password); CredentialCache credCache = new CredentialCache (); credCache. add (new Uri (uri), "Basic", new NetworkCredential (username, password); return credCache;} private static string GetAuthorization (string username, string password) {string authorization = string. format ("{0 }:{ 1}", username, password); return "Basic" + Convert. toBase64String (new ASCIIEncoding (). getBytes (authorization);} # endregion}
Finally, we have to talk about the gold data API. It is clear that if the verification condition is not met (required or repeated), the gold data will return 400 and give a prompt.
But! No prompt, but the system will return the 400 Bad Request! It took me half a day to understand that the page request did not exist or other requests were wrong, because the prompt of saying yes was not provided ..