Jump to content

posting values using curl, invalid http request


ibinod

Recommended Posts

Hi, i am trying to make a simple code that can submit content automatically using curl

 

i have the following code

 

This is to login to the site which works perfectly

 

		$curl_connection = curl_init("http://www.familyfriendsphotos.com/login.php");
		curl_setopt($curl_connection, CURLOPT_CONNECTTIMEOUT, 300);
		curl_setopt($curl_connection, CURLOPT_SSL_VERIFYPEER, false);
		curl_setopt($curl_connection, CURLOPT_FOLLOWLOCATION, 1); 
		curl_setopt ($curl_connection, CURLOPT_POST, 1);
		curl_setopt($curl_connection, CURLOPT_ENCODING, 'gzip,deflate');
		curl_setopt($curl_connection, CURLOPT_AUTOREFERER, true);
		curl_setopt($curl_connection, CURLOPT_RETURNTRANSFER, 1);
		curl_setopt($curl_connection, CURLOPT_TIMEOUT, 10);
		curl_setopt($curl_connection, CURLOPT_COOKIEJAR, ‘cookie.txt’);
		curl_setopt($curl_connection, CURLOPT_COOKIEFILE, ‘cookie.txt’);


		$post_data['uname'] = $dir['user'];
		$post_data['pswd'] = $dir['pass'];
		$post_data['Submit']="Login";

	 	foreach ( $post_data as $key => $value) {
			//echo ("Key:".$key."=>".$value);
			$post_items[] = $key."=".$value;
		}
		$post_string = implode ("&", $post_items); 
		//echo $post_string;
		curl_setopt($curl_connection, CURLOPT_POSTFIELDS, $post_string); 
		$result = curl_exec($curl_connection);

		unset($post_data);

 

 

and to submit the article  i have the following code

curl_setopt($curl_connection, CURLOPT_URL, 'http://www.familyfriendsphotos.com/submitart.php');
$post_data['author'] = $article['author'];
$post_data['parentId'] = $article['cat'];
$post_data['f_arttitle'] = $article['title'];
$post_data['f_artsummary'] = $article['short_desc'];
$post_data['f_artbody'] = $article['article'];
$post_data['f_artres'] = $article['resource'];
$post_data['f_artkey'] = $article['keywords'];
$post_data['key']="avachars_key";
$post_data['submit'] = "Submit";


foreach ( $post_data as $key => $value) 
{
    $post_items[] = $key."=".$value;
}
$post_string = implode ("&", $post_items); 
curl_setopt($curl_connection, CURLOPT_POSTFIELDS, $post_string); 
$result = curl_exec($curl_connection);
echo ($result);
curl_close($curl_connection); 

 

But i get invalid http request like this

ERROR

The requested URL could not be retrieved

 

While trying to process the request:

 

POST /thankyou.php HTTP/1.1

Host: www.familyfriendsphotos.com

Accept: */*

Accept-Encoding: gzip,deflate

Referer: http://www.familyfriendsphotos.com/thankyou.php

Cookie: PHPSESSID=5f2127a0cd9045e3f38d1ab0b3684d2f

Content-Length: 3585

Content-Type: application/x-www-form-urlencoded

Expect: 100-continue

 

 

The following error was encountered:

 

    * Invalid Request

 

Some aspect of the HTTP Request is invalid. Possible problems:

 

    * Missing or unknown request method

    * Missing URL

    * Missing HTTP Identifier (HTTP/1.0)

    * Request is too large

    * Content-Length missing for POST or PUT requests

    * Illegal character in hostname; underscores are not allowed

 

Please tell me what should i do to fix this

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.