0

如何从中得到'ssl_result_message'string这是一个curl回应):

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<!-- process-transaction-response -->

<html>
<head>
    <meta content=
    "1;url=http://www.xxx.com/perfect-process-status.php?ssl_email=&amp;ssl_status=TEST+MODE&amp;ssl_cvv2_response=P&amp;ssl_ship_to_phone=&amp;ssl_last_name=&amp;ssl_ship_to_country=&amp;ssl_ship_to_state=&amp;ssl_eci_ind=&amp;ssl_account_balance=0.00&amp;ssl_ship_to_zip=&amp;ssl_get_token=&amp;ssl_token=&amp;ssl_result_message=APPROVED&amp;ssl_token_response=&amp;ssl_country=&amp;ssl_city=&amp;ssl_phone=&amp;ssl_invoice_number=1876&amp;ssl_ship_to_address2=&amp;ssl_ship_to_address1=&amp;ssl_txn_id=00000000-0000-0000-0000-00000000000&amp;ssl_result=0&amp;ssl_customer_code=14&amp;ssl_ship_to_company=&amp;ssl_avs_response=X&amp;ssl_approval_code=123456&amp;ssl_ship_to_last_name=&amp;ssl_avs_zip=&amp;ssl_exp_date=0415&amp;ssl_ship_to_city=&amp;ssl_ship_to_first_name=&amp;ssl_avs_address=&amp;ssl_address2=&amp;ssl_first_name=&amp;ssl_amount=30.00&amp;ssl_state=&amp;ssl_card_number=37**********0005&amp;ssl_txn_time=10%2F29%2F2013+02%3A28%3A11+AM"
    http-equiv="refresh">
    <style type="text/css">
         BODY, TD, INPUT, SELECT, TEXTAREA, BUTTON, .normal {font-family:arial,helvetica,sans-serif; font-size:10pt; font-weight:normal; } .small {font-size: 10pt} .medium {font-size: 14pt} .large {font-size: 18pt} 
    </style>

    <title></title>
</head>

<body>
    <form action="#" id="frmMenu" method="post" name="frmMenu">
        <input name="dispatchMethod" type="hidden"> <input name=
        "permissionDesc" type="hidden"> <input name="menuAction" type="hidden">
        <input name="thClientID" type="hidden" value="">
    </form>
</body>
</html>

这是来自:

print_r(htmlspecialchars($post_response));
4

1 回答 1

1

尝试 preg_match:

if (preg_match('/ssl_result_message\=([^&]+)/m', $response, $match)) {
    var_dump($match);
}

结果是:

array(2) {
  [0]=>
  string(27) "ssl_result_message=APPROVED"
  [1]=>
  string(8) "APPROVED"
}
于 2013-10-29T06:41:15.023 回答