私はページの読み込み時にデータをポストするindexpage.aspxを持っています。このページでは、私は今、私はここにクラスがnewsoft jsonを使わずに文字列の辞書から各キー値を取得
Public Shared Function POSTAPI(cmd As String, Optional parms As SortedList(Of String, String) = Nothing) As Dictionary(Of String, Object)
Dim post_data As String = ""
For Each parm As KeyValuePair(Of String, String) In parms
If post_data.Length > 0 Then
post_data += "&"
End If
post_data += parm.Key + "=" + Uri.EscapeDataString(parm.Value)
Next
Dim keyBytes As Byte() = encoding.GetBytes(s_privkey)
Dim postBytes As Byte() = encoding.GetBytes(post_data)
Dim hmacsha512 = New System.Security.Cryptography.HMACSHA512(keyBytes)
Dim hmac As String = BitConverter.ToString(hmacsha512.ComputeHash(postBytes)).Replace("-", String.Empty)
' do the post:
Dim cl As New System.Net.WebClient()
cl.Headers.Add("Content-Type", "application/x-www-form-urlencoded")
cl.Headers.Add("HMAC", hmac)
cl.Encoding = encoding
Dim ret = New Dictionary(Of String, Object)()
Try
Dim resp As String = cl.UploadString("https://www.coinpayments.net/api.php", post_data)
Dim decoder = New System.Web.Script.Serialization.JavaScriptSerializer()
ret = decoder.Deserialize(Of Dictionary(Of String, Object))(resp)
Catch e As System.Net.WebException
ret("error") = "Exception while contacting CoinPayments.net: " + e.Message
Catch e As Exception
ret("error") = "Unknown exception: " + e.Message
End Try
Return ret
End Function
に成功し、その投稿が、「get_callback_address」または 'への呼び出しが成功だ、postapi機能を持つ支払いクラスを持つ文字列
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
Dim openWith As New SortedList(Of String, String)
' Add some elements to the list. There are no
' duplicate keys, but some of the values are duplicates.
openWith.Add("version", "1")
openWith.Add("key", ConfigurationManager.AppSettings("publickey"))
openWith.Add("cmd", "get_callback_address")
openWith.Add("currency", "coin")
Call POSTAPI("get_callback_address", openWith)
End Sub
のリストを作成しました
{
"error":"ok",
"result":{
"address":"1BitcoinAddress",
"pubkey":"",
"dest_tag":100,
}
}
は、上記のキーと値を返しているのとおりです。get_deposit_address'コマンドを使用すると、この(JSON)と同様の結果が得られます。今私の質問は、私は結果の値を取得し、それが私に "1BitcoinAddress
"、 "pubkey
"と私のデータベースに保存する(私はそれを保存することができます結果のキーの3つの値を取得する私のデータベース」。
ありがとう。
[VBを使用したJSON http投稿応答の読み方](https://stackoverflow.com/questions/15979742/how-to-read-json-http-post-response-using-vb) –
なぜそれを分割する必要がありますか?これもまた辞書です。 'ret(" result ")'の値を 'Dictionary(String、String)'にキャストできませんか? – Icepickle
ret.item( "result")の別の辞書値にキャストする必要がありますか?私がそれをしたいのであれば、どうすれば辞書から3つの値を取得してdbに保存するのですか –