First of all, spit the Gold Data API document http://help.jinshuju.net/articles/api-intro.html written very rough ah ... Anyway, I didn't really see it.
Take the form API example, just tell you an address https://jinshuju.net/api/v1/forms/ex27t2 , then, then, then no, I guess everyone can guess it ex27t2 should be a change, but what to fill ...
Here should be a value of your form, as if only in this place has this value, other places I did not find.
And the submission of the consultation work order is useless, to my reply to the message only "we do not provide such technical support at this time." If you have any further questions, please continue to submit your ticket. If you still have questions, you can check out our help Center. Welcome to pay attention to gold data official (Gold Data Service number/jinshuju-service). ”
Hands-on, clothed ...
Okay, no more talking about the other, directly on the code
Public classJinshuju {Private Static stringKey ="9hh6fibloqdrgin4q_r6x"; Private Static stringSecret ="Z3rsib8heqbfau6zwrpro"; /// <summary> ///Get Form API/// </summary> /// <returns></returns> Public Static stringGetfromapi () {stringURI ="Https://jinshuju.net/api/v1/forms/RsE5EC"; stringresult =string. Empty; WebRequest Request= WebRequest.Create (NewUri (URI)); Request. Credentials=Getcredentialcache (URI, Key, Secret); Request. Headers.add ("Authorization", Getauthorization (Key, Secret)); Request. Timeout= -; WebResponse response=request. GetResponse (); Stream Stream=Response. GetResponseStream (); StreamReader SR=NewStreamReader (stream); Result=Sr. ReadToEnd (); Sr. Close (); Stream. Close (); returnresult; } /// <summary> ///Submit Data API/// </summary> /// <param name= "Jsondata" ></param> /// <returns></returns> Public Static stringPostfromapi (stringjsondata) { stringURI ="Https://jinshuju.net/api/v1/forms/RsE5EC"; stringresult =string. Empty; WebRequest Request= WebRequest.Create (NewUri (URI)); Request. Credentials=Getcredentialcache (URI, Key, Secret); Request. Headers.add ("Authorization", Getauthorization (Key, Secret)); Request. Timeout= -; byte[] bytes =Encoding.UTF8.GetBytes (Jsondata); Request. Method="POST"; Request. ContentType="Application/json"; stringparaurlcoded =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=NewStreamReader (stream); Result=Sr. ReadToEnd (); Sr. Close (); Stream. Close (); returnresult; } #region# Generate Http Basic Access Credentials #Private StaticCredentialCache Getcredentialcache (stringUristringUsernamestringpassword) { stringauthorization =string. Format ("{0}:{1}", username, password); CredentialCache Credcache=NewCredentialCache (); Credcache.add (NewUri (URI),"Basic",Newnetworkcredential (username, password)); returnCredcache; } Private Static stringGetauthorization (stringUsernamestringpassword) { stringauthorization =string. Format ("{0}:{1}", username, password); return "Basic"+ convert.tobase64string (Newasciiencoding (). GetBytes (authorization)); } #endregion }
Finally, you have to spit down the gold data API, clearly agreed, if not meet the check conditions (required/repeat, etc.), the gold data will return 400, and give a hint.
But! And no hint, just return to the request! I took a long while to understand that the page request does not exist or other requests are wrong, because the good hints did not give out.
C # call Gold Data API