mechanical turk submitting external hit with curl


rather dry, but I spent a day figuring this out.  The below lets you submit an external MTurk hit via a simple php file.  The file uses Curl.

Hope this helps someone.


$url = $_GET[‘url’];

$myParams = “assignmentId=” . $_GET[‘assignmentId’] . “&dummy=1″;

if($url==”real”)$url= ‘’;
else $url= ‘’;

//open connection
$ch = curl_init();

//set the url, number of POST vars, POST data
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, “POST”);
curl_setopt($ch,CURLOPT_POST, 2);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
//execute post
$result = curl_exec($ch);

//close connection