有人可以帮我吗?,我遇到了一个问题,我正在尝试使用curl将数据发送到其余应用程序:这是我的代码:
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://dev.entrale.org.mx/api/vacantes/10057",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"vacante\"\r\n\r\nCóadóróó 3\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"estado\"\r\n\r\nCiudad de México\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"municipio\"\r\n\r\nBenito Juarez\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"requerimientos\"\r\n\r\nholllllll mun\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"categoria\"\r\n\r\n[\"Ventas\"]\ndescripcion\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"descripcion\"\r\n\r\nLo ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore \r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"numero_vacantes\"\r\n\r\n2\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"salario\"\r\n\r\n1,500 o menos\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"mostrar_salario\"\r\n\r\nsi\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"comentarios\"\r\n\r\nLorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore \r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"tipo_jornada\"\r\n\r\nTiempo completo\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"forma_contratacion\"\r\n\r\n\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"prestaciones\"\r\n\r\n\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"nivel_educativo\"\r\n\r\nPrimaria concluída\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"idiomas\"\r\n\r\nBásico\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW--",
CURLOPT_HTTPHEADER => array(
"content-type: multipart/form-data; charset=gb18030; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW",
"Accept-Charset: gb18030",
"Accept-Language: en-us,en;q=0.5",
"entrale-api-key: a8a83675202cda08bfb0a2db159dc599",
"postman-token: 4ae185e4-11e2-bb46-9b67-905d33f1f826"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
在这一点上无论如何都没什么大不了,但是出于测试目的,我正在尝试以不同于utf-8的另一种编码发送数据,但是我尝试过的每件事似乎都没用(测试包括检查发生了什么情况)带有重音符号的字符,而不是将其存储在数据库中)。我正在使用:
CURLOPT_HTTPHEADER => array(
"content-type: multipart/form-data; charset=gb18030; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW",
"Accept-Charset: gb18030",
但仍在utf-8中发送数据,因此:
1.-如何发送具有不同编码(ascii,iso ...)的数据?
2.-有什么方法可以使我的其余代码符合要求?
非常感谢。