7

I want to create an mturk HIT that has a URL like so:
www.example.com?source=worker_id
where worker_id is the worker's ID code. I'm initially going to create these from the mturk web UI, then once I get it working right, from PHP. But I can't figure out how to get at the worker's ID from the modified-HTML syntax of an mturk HIT.

Dan
  • 163
  • 2
  • 6
  • This may help someone figure out a solution - I don't know javascript, but pasting javascript:alert("Worker ID is "+s.prop1); in the addressbar generates a popup window with the worker ID. Can you use javascript in the HIT to construct the URL? – Dan May 27 '10 at 04:37
  • You might find this easier to do with an external question. – James Moore Oct 28 '11 at 00:13

2 Answers2

11

Mechanical Turk will call your website with a URL that looks like:

www.example.com/?hitId=2384239&assignmentId=ASD98ASDFADJKH&workerId=ASDFASD8

In your php page that is at that location you can access the workerId (as well as the other Ids) like so:

<?php
$hitId        = $_REQUEST["hitId"];
$assignmentId = $_REQUEST["assignmentId"];
$workerId     = $_REQUEST["workerId"];

echo "Hit ID: $hitId\n";
echo "Ass ID: $assignmentId\n";
echo "Worker ID: $workerId\n";
?>
Nate
  • 2,940
  • 3
  • 22
  • 24
2

Note that the workerId is NOT sent during the preview, only after the HIT has been accepted. If you're using an External HIT, you can create a cookie to see if it's a worker who has accepted a previous hit, but of course that method is unreliable.

Tac Tacelosky
  • 3,165
  • 3
  • 27
  • 28