所以我目前在蟒蛇麻煩移動蟒蛇請求node.js的請求
import requests
import json
address = "*address here*"
viewkey = "*viewkey here*"
headers = {'content-type': 'application/json'}
url = "https://api.mymonero.com:8443/get_address_txs"
data = {"address":address,"view_key":viewkey}
data = json.dumps(data)
response = requests.post(url, data=data, headers=headers)
print(response.text)
正常運行的代碼和我想移動到到的NodeJS它我寫
var request = require('request');
var options = {
url: 'https://api.mymonero.com:8443/get_address_txs',
headers: {'content-type': 'application/json'},
data: JSON.stringify({
address:"address",
viewkey:"viewkey"
})
};
request.post(options,function(error, response, body) {
console.log(body);
})
另一個程序整合
我認爲代碼將是相同的,但顯然不是我從服務器獲得第二段代碼的錯誤。請有人可以幫我遷移嗎?
注意:我知道python中的請求有一個json屬性,爲了清楚起見,我已經用python這樣寫了它。
爲了記錄我與JavaScript得到的迴應是:
{
"Error": "Problems parsing JSON"
}
當我從蟒蛇得到:
{
"total_received": "152840132538",
"scanned_height": 2589644,
"scanned_block_height": 1320308,
"start_height": 2586111,
...
}
只是好奇,你爲什麼要將python轉換爲nodejs? – niceman
因爲在Python中並不存在一堆很酷的庫,並且不想永遠移植它們。 –
hmmm酷庫中的節點,例子? – niceman