如何在以太坊平台上的Solidity中处理REST API响应?

问题描述

我在Ethereum平台上使用Solidity语言调用REST API。我需要处理回应。 API返回true或false。您能帮忙处理答复吗?

提前谢谢! 我正在使用以下代码:

导入“ github.com/oraclize/ethereum-api/provableAPI.sol”;

contract UrlRequests is usingProvable {

event LogNewProvableQuery(string description);

event LogResult(string result);
constructor()
    public
{
    provable_setProof(proofType_Android | proofStorage_IPFS);
}

function __callback(
    bytes32 _myid,string memory _result,bytes memory _proof
)
    public
{
    require(msg.sender == provable_cbAddress());
    emit LogResult(_result);
}

function request(
    string memory _query,string memory _method,string memory _url,string memory _kwargs
)
    public
    payable
{
    if (provable_getPrice("computation") > address(this).balance) {
        emit LogNewProvableQuery("Provabl   e query was NOT sent,please add some ETH to cover for the query fee");
    } else {
        emit LogNewProvableQuery("Provable query was sent,standing by for the answer...");
        provable_query("computation",[_query,_method,_url,_kwargs]
        );
    }
}
/**
 * @dev Sends a custom content-type in the header and returns the header used
 * as result. Wrap the first argument of computation ds with helper needed,* such as JSON in this case
 */
 function requestPost()
    public
    payable
{
    request("testaccaount","POST","https://xxxxtest",'{"json": { "username": "usertest","password": "passwordtest"}}');
} 

}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)