我可以通过 CURL 完成此操作。我已经使用curl方法发布到url并获取xml结果,稍后由php方法 simplexml_load_string() 解析
// open curl connection
$ch = curl_init('https://api.neteller.com/netdirect');
// get the vars from POST request and add them as POST fields
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query([
'version' => $_POST['version'],
'amount' => urlencode($_POST['amount']),
'currency' => $_POST['currency'],
'net_account' => urlencode($_POST['net_account']),
'secure_id' => urlencode($_POST['secure_id']),
'merchant_id' => urlencode($_POST['merchant_id']),
'merch_key' => urlencode($_POST['merch_key']),
'merch_transid' => urlencode($_POST['merch_transid']),
'language_code' => $_POST['language_code'],
'merch_name' => urlencode($_POST['merch_name']),
'merch_account' => urlencode($_POST['merch_account']),
'custom_1' => urlencode($_POST['custom_1']),
'custom_2' => urlencode($_POST['custom_2']),
'custom_3' => urlencode($_POST['custom_3']),
'button' => 'Make Transfer'
]));
// set other curl options
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
// execute post
$output = curl_exec($ch);
$info = curl_getinfo($ch);
$error = '';
$approval = '';
// check if curl request processed or not
if(($output == false) or ($output == '')) {
$curlerror = curl_error($ch);
$error = 'Server Error. ';
} else {
$response = simplexml_load_string($output);
$approval = $response->approval;
}
// close curl connection
curl_close($ch);