Page 1 of 1

cURL Post Error

Posted: Wed Feb 19, 2003 11:19 am
by justravis
I am trying to post to a form using cURL. Getting the "405 Method Not Allowed" error.

cURL Official Web States This:
4.5.5 "405 Method Not Allowed"

The method specified in the Request-Line is not allowed for the resource
identified by the Request-URI. The response MUST include an Allow header containing a list of valid methods for the requested resource.
Can someone help me understand the solution to this problem?

Here's more info if u need it:

Code:

Code: Select all

<?php
#Initialize a CURL Session
$curl = curl_init();

#OPTIONS SET

#Set this option to a non-zero value if you want CURL to report everything that is happening.
curl_setopt($curl, CURLOPT_VERBOSE, 1);

#Set this option to a non-zero value if you don't want PHP to display a progress meter for CURL transfers.
curl_setopt($curl, CURLOPT_NOPROGRESS, 0);

#Set this option to a non-zero value if you want PHP to do a regular HTTP POST. This POST is a normal application/x-www-form-urlencoded kind, most commonly used by HTML forms.
curl_setopt($curl, CURLOPT_POST, 1);

#Form that is being submitted.
$form= 'http://reference.justravis.com/php/form_processing/email/1_-_basic_-_tp/form.htm';

#This is the URL that you want PHP to fetch. You can also set this option when initializing a session with the curl_init() function.
curl_setopt($curl, CURLOPT_URL, $form);

#Fields to be posted.
$name='Mr. Curl';
$email='curl@justravis.com';
$subject='Curl Message';
$msg ='The form was submitted through cURL.';

$fields = "name='$name'&email='$email'&subject='$subject'&msg='$msg'";

#/Fields

#Pass a string containing the full data to post in an HTTP "POST" operation.
curl_setopt($curl, CURLOPT_POSTFIELDS, $fields);

#/OPTIONS SET

#Perform a CURL session.
curl_exec($curl);

#Close a CURL session.
curl_close($curl);

?>
Script:
http://reference.justravis.com/php/misc ... curl_-_tp/