View Full Version : cURL Not Submitting Properly?

08-25-2009, 10:20 AM
I am using this code:

$post = array();
$post["Sentence"] = "the dog jumped over the lazy sheep";
$post["Constituents"] = "checked";
$post["NullLinks"] = "checked";
$post["AllLinkages"] = "checked";
$post["LinkDisplay"] = "on";
$post["ShortLength"] = "6";
$post["PageFile"] = "/docs/submit-sentence-4.html";
$post["InputFile"] = "/scripts/input-to-parser";
$post["Maintainer"] = "sleator@cs.cmu.edu";
$post["submit"] = "Submit one sentence";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"http://www.link.cs.cmu.edu/cgi-bin/link/construct-page-4.cgi#submit");
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv: Firefox/2.0.0");
curl_setopt($ch, CURLOPT_REFERER, "http://link.cs.cmu.edu/link/submit-sentence-4.html");
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
$results = curl_exec($ch);
echo $results;

And trying to fetch the page that would contain the results. I instead, however, get a page that takes about 20 seconds to load that contains an error message. I have no idea what I'm doing wrong, and I have tried nearly everything. The page with the original form on it is: http://www.link.cs.cmu.edu/link/submit-sentence-4.html. When I just copy and paste the form their page to my page, then submit it manually, it works fine.

08-25-2009, 08:43 PM
i think you should use urlencode to endoce them and use urldecode to decode and use them in your destination php script. This ensures sending of variable values accurately over pages...

08-25-2009, 11:30 PM
Just tried that, it doesn't help. Thanks though.

08-26-2009, 12:30 AM
This fixed it:

$post = http_build_query($post);