我想在我的谷歌頁保存的用戶名密碼&,我能夠通過捲曲與下面的代碼,通過這些信息:如何在PHP中通過cURL傳遞特殊字符?
foreach ($fields as $key => $value) {
if (!empty($value) && !is_null($value)) {
$fields_string .= $key . '=' . $value . '&';
} else {
$fields_string .= $key . '=-&';
}
}
rtrim($fields_string, '&');
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, count($fields));
curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
$gResult = curl_exec($ch);
但在密碼字段中的特殊字符的時候遇到了問題。 因爲用戶可以使用任何特殊字符,包括「&」 charcater當這個「&」字符用來定義爲不同的字符串
有沒有擺脫這個問題的任何可能的方式捲曲?
你得到使用wp_remote_post()函數同樣的問題? –
實際上這是原始的PHP代碼。我不使用WP :( –
'$ fields_string = http_build_query($ fields);' – DarkBee