我正在尝试在https://www.igolder.com/PGP/encryption/提交表单,并使用PHP和cURL从“加密消息”textarea返回结果。我可以看到包含以下代码的页面,但我不知道它是否正在提交表单,我不知道如何获得结果。此外,是的,= NXwT意味着在PGP Public Key textarea的单独一行。任何反馈将不胜感激!这是我的代码如下:
//create array of data to be posted
$post_data['ctl00$cp$txtPublicKey'] = 'mQENBFfWrk0BCACPDJk8f6GOpQewp0AtP5CrhstpazsYPG9r+8wWamSgVYbIwdS8/bdnVdIu7Be680m3VcjtZWwG9wiomTXCx5RargREqNICigzPTU0f/CgHEMFoZQn2bWz1YXBrpYb+qgxMweVe1T4uz8sOeHzAebMAQCdNVEwDu4o90vi+Pz3jqgSEpJyhe4RqOgEdkkrtGaEUnNr2IO8gCSmPAeQW6qFNcJsl7iWfeY7LHMv6A77n/1mGhdp4h0E+V6ElUNPjeEj9I1QYSIXRxDcejvcq5HrF27DyQ1mN1TgdauAkGdqRuIJsMDmEaYtLm3fIAwpbiAcJu6fmz7eAnBz5scTlLvEZABEBAAG0GmR1c3Rpbm9ybW9uZEBjcmVpZ2h0b24uZWR1iQEcBBABAgAGBQJX1q5NAAoJEKd43LZ3nczviUoIAIAzstgpn++GAfwHs7wMdjQbKvK3LB7hZKfskiATVWxafRvNGP9Gv0PPF+ly5WLt0PjLsOc6KV98T5jtF3h0rvTZK4viZJD6JFAgiaWzL0+w5a/ksUMEgMdx4xHM/k+sSbtBlha+GI72IMsU/0dKrYkSkZ5BpUoepk5OtRvu37Pg5dSW0Zx/cd+8bnVMBK6Ri8yT0Lvg+5w0KSCn5LvXtpGKc87TJgMBHWRa3qikmw3XWqPCza+APbTjZ/WlLtA0lpP7txfbYsTQObVdiZ7DFOb1n4OxpWxrvV8e60VazKBmv4daFyim+qWySsvYCBmwn8+8r+J/5OdKhG7tAW71qxY=
=NXwT';
$post_data['ctl00$cp$txtMsgToEncrypt'] = 'Test Message';
$post_data['ctl00$cp$btnGeneratePgpKeys'] = 'Encrypt Message';
//traverse array and prepare data for posting (key1=value1)
foreach ( $post_data as $key => $value) {
$post_items[] = $key . '=' . urlencode($value);
}
//create the final string to be posted using implode()
$post_string = implode('&', $post_items);
//create cURL connection
$ch = curl_init();
// sets the cURL options
$options = array(
CURLOPT_URL => "https://www.igolder.com/PGP/encryption/",
CURLOPT_RETURNTRANSFER => true, // return web page
CURLOPT_HEADER => false, // don't return headers
CURLOPT_FOLLOWLOCATION => true, // follow redirects
CURLOPT_MAXREDIRS => 10, // stop after 10 redirects
CURLOPT_ENCODING => "", // handle compressed
CURLOPT_USERAGENT => $_SERVER["HTTP_USER_AGENT"], // name of client
CURLOPT_AUTOREFERER => true, // set referrer on redirect
CURLOPT_CONNECTTIMEOUT => 30, // time-out on connect
CURLOPT_TIMEOUT => 30, // time-out on response
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_COOKIEJAR => 'cookie.txt',
CURLOPT_COOKIEFILE => 'cookie.txt',
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $post_string
);
curl_setopt_array($ch, $options);
// execute cURL request
$result = curl_exec($ch);
// prints the cURL result
print_r($result);
/******* instead of printing the entire page, I want to just get the value in the textarea with the name of ctl00$cp$txtEncryptedMessage *******/
//close the connection
curl_close($ch);
?>