2017 © Pedro Peláez
 

library mturk_php

mTurk_PHP wrapper

image

oceanapplications/mturk_php

mTurk_PHP wrapper

  • Thursday, August 13, 2015
  • by oceanapplications
  • Repository
  • 1 Watchers
  • 1 Stars
  • 176 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 5 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

mturk-php

Complete Mechanical Turk API written in PHP that uses the same names as the official documentation, (*1)

mturk.php is a small library that sends requests to Mechanical Turk. It is much simpler than other libraries which redefine every function that Mechanical Turk recognizes. This saves you time so you don't have to worry about the library, just the Mechanical Turk API., (*2)

mturk.php is written in the spirit of my original mTurk library, mturk.py. Most names are kept the same between the two., (*3)

Read the official mTurk API docs here., (*4)

Example configuration file (mturkconfig.json), (*5)

{
"use_sandbox" : false,
"verify_mturk_ssl" : true,
"aws_key" : "ACCESSID",
"aws_secret_key" : "PASSWORD"
}

Getting your balance, (*6)

$m = new MechanicalTurk();
$r = $m->request('GetAccountBalance');
if (MechanicalTurk::is_valid($r))
    echo 'Your balance is: ' . MechanicalTurk::get_response_element($r, 'Amount');

Creating a HIT, (*7)


<QuestionForm xmlns="http://mechanicalturk.amazonaws.com/AWSMechanicalTurkDataSchemas/2005-10-01/QuestionForm.xsd">
  <Question>
    <QuestionIdentifier>answer</QuestionIdentifier>
    <QuestionContent>
      <Text>Hello world :^)</Text>
    </QuestionContent>
    <AnswerSpecification>
      <FreeTextAnswer/>
    </AnswerSpecification>
  </Question>
</QuestionForm>
QUESTION;

$qual = array(
    array('QualificationTypeId' => MechanicalTurk::N_APPROVED,
          'Comparator' => 'GreaterThan',
          'IntegerValue' => 18),
    array('QualificationTypeId' => MechanicalTurk::P_APPROVED,
          'Comparator' => 'GreaterThan',
          'IntegerValue' => 75)
);

$reward = array(array('Amount' => 5, 'CurrencyCode' => 'USD'));

$createhit = array("Title" => "Testing mturk-php API",
                   "Description" => "https://github.com/ctrlcctrlv/mturk-php",
                   "Keywords" => "testing, one, two, three",
                   "Reward" => $reward,
                   "Question" => $question,
                   "QualificationRequirement" => $qual,
                   "AssignmentDurationInSeconds" => 90,
                   "LifetimeInSeconds" => (60*60*24));

$m = new MechanicalTurk();
$r = $m->request('CreateHIT', $createhit);
var_dump($r);
var_dump(MechanicalTurk::is_valid($r));
?>

If you find any bugs please open a new issue., (*8)

The Versions

13/08 2015

dev-master

9999999-dev

mTurk_PHP wrapper

  Sources   Download

MIT

by Ocean Applications

mturk

13/08 2015

v1.2

1.2.0.0

mTurk_PHP wrapper

  Sources   Download

MIT

by Ocean Applications

mturk

13/08 2015

v1.1

1.1.0.0

mTurk_PHP wrapper

  Sources   Download

MIT

by Ocean Applications

mturk

13/08 2015

v1

1.0.0.0

mTurk-PHP wrapper

  Sources   Download

MIT

by Ocean Applications

mturk