2017 © Pedro Peláez
 

library mturk-php

Provides a simple library to communicate with the Amazon Mechanical Turk API. This is a fork of ctrlcctrlv/mturk-php

image

cmdev/mturk-php

Provides a simple library to communicate with the Amazon Mechanical Turk API. This is a fork of ctrlcctrlv/mturk-php

  • Wednesday, February 15, 2017
  • by developers.crowdmetric
  • Repository
  • 1 Watchers
  • 1 Stars
  • 37 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 5 Forks
  • 0 Open issues
  • 1 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)

https://github.com/crowdmetricdevs/mturk-php/edit/master/README.md, (*5)

Installation

Install by adding mturk-php to your composer.json file:, (*6)

require : {
    "cmdev/mturk-php": "dev-master"
}

or with a composer command:, (*7)

composer require "cmdev/mturk-php": "dev-master"

Example configuration file (mturk.php), (*8)

$config = [
    "use_sandbox" => false,
    "verify_mturk_ssl" => true,
    "aws_key" => "ACCESSID",
    "aws_secret_key" => "PASSWORD"
];

Getting your balance, (*9)

$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, (*10)


<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., (*11)

The Versions

15/02 2017

dev-master

9999999-dev https://github.com/crowdmetricdevs

Provides a simple library to communicate with the Amazon Mechanical Turk API. This is a fork of ctrlcctrlv/mturk-php

  Sources   Download

MIT

The Requires

  • php >=5.6

 

by Developers Crowdmetric

api amazon mechanical turk mturk mturk-php