설정이 간단합니다. Joomla 계정이 생성 된 후 데이터베이스 (cURL 게시)를 다른 데이터베이스 지원 응용 프로그램 (MS SQL이 포함 된 ASP)으로 보내는 Joomla 전자 상거래 사이트 (MySQL 백엔드)입니다.cURL 뒤에 공백없이 저장된 데이터
때때로이 데이터는 공백없이 수신 데이터베이스에 저장되는 것이 문제입니다. 예를 들면 : Joomla 사이트에서 수집 된 주소는 "123 example road"으로 데이터베이스에 저장되지만 수신 데이터베이스에는 "123exampleroad"으로 저장됩니다. 이것은 항상 발생하지 않습니다 - 그래서 나는 오히려 그 원인에 대해 당혹 스럽습니다.
누구도 그런 문제가 있습니까? 어떤 도움을 주셔서 감사합니다.
이는 컬 코드 모습입니다 : 하나 개의 매개 변수가 base64
를 사용으로 인코딩 된 데이터를 전송하는
//create array of data to be posted
foreach($registrationfields as $field) {
if($field->name == 'email') $field->name = 'user_email';
if($field->name == 'delimiter_sendregistration') continue;
if($field->type == 'captcha') continue;
if($field->type == 'delimiter') continue;
switch($field->name) {
case 'country':
require_once(CLASSPATH.'ps_country.php');
$country = new ps_country();
$dbc = $country->get_country_by_code($dbbt->f($field->name));
if($dbc !== false) $val = $dbc->f('country_name');
break;
default:
$val = $dbbt->f($field->name);
break;
}
$post_data[$field->name] = $val;
}
$post_data['order_id'] = $order_id;
$post_data['order_date'] = $order_date;
$post_data['order_status'] = $order_status;
$post_data['username'] = $username;
//traverse array and prepare data for posting (key1=value1)
foreach ($post_data as $key => $value) {
$post_items[] = $key . '=' . $value;
}
//create the final string to be posted using implode()
$post_string = implode ('&', $post_items);
//create cURL connection
$curl_connection =
curl_init('http://--url-here');
//set options
curl_setopt($curl_connection, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($curl_connection, CURLOPT_USERAGENT,
"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)");
curl_setopt($curl_connection, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl_connection, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl_connection, CURLOPT_FOLLOWLOCATION, 1);
//set data to be posted
curl_setopt($curl_connection, CURLOPT_POSTFIELDS, $post_string);
//perform our request
$result = curl_exec($curl_connection);
//show information regarding the request
print_r(curl_getinfo($curl_connection));
echo curl_errno($curl_connection) . '-' .
curl_error($curl_connection);
//close the connection
curl_close($curl_connection);
공간이 일부 시간에만 올바르게 인코딩/디코딩되는 것은 흥미로운 일입니다. 나는 이것이 어떻게 작동하는지 보게 될 것이다. - 고마워! – Ahmed
다른 상황에서 문자열 인코딩 문제에 대해 많이 알지 못한다는 것을 인정하지만, 개발자가 텍스트를 url param으로 보내는 동안 공백을 피하려고 많은 시간을 보았습니다. 때로는 base64이고 때로는 공백을 "+"기호로 바꿉니다 (다른 방법으로 "+"를 사용하지 않을 것이라고 확신하는 경우) – ex3v
나는 이것을 시도했지만 제대로 작동하지 않았습니다. 왜 그런지 말하기 어렵습니다. – Ahmed