[Solved] Php Curl post data help needed.
Hello, i got this code.
Its working good as long i post small data.
If i try to post larger text it will post only part of it.
Can someone help me with curl settings.
Code:
Hello, i got this code.
Its working good as long i post small data.
If i try to post larger text it will post only part of it.
Can someone help me with curl settings.
Code:
PHP:
$post_data['title'] = $game;
$post_data['name'] = 'test';
$post_data['comment'] = $post_body;
//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://www.1.com/form_post_test.php');
//set options
curl_setopt($curl_connection, CURLOPT_CONNECTTIMEOUT, 190);
curl_setopt($curl_connection, CURLOPT_USERAGENT,"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)");
curl_setopt ($curl_connection, CURLOPT_HTTPHEADER, array(
'Content-type: application/x-www-form-urlencoded',
'Accept: text/html',
'Expect: ',
) );
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);
curl_error();
//close the connection
curl_close($curl_connection);
Last edited: