dadeg/php-crowdflower

此包的最新版本(v0.1.1)没有提供许可证信息。

PHP 库,用于与 Crowdflower API v1 交互

v0.1.1 2014-12-16 14:10 UTC

README

Code Climate Build Status

examples 文件夹中包含了与 CrowdFlower API 每种交互方式的示例。测试覆盖率几乎达到100%。我每天都在使用这个包,它非常可靠。要自己运行测试,您需要将 tests/fixtures 中的 API 密钥替换为您的 API 密钥。

安装

添加到 composer.json

  "dadeg/php-crowdflower": "0.1.*"

更新现有项目的 composer

  composer update dadeg/php-crowdflower

新项目使用 composer 安装

  composer install

入门指南

use CrowdFlower\Account;
$crowd = new Account($apiKey);

获取现有作业

// get list of ten most recent jobs from account
$jobs = $crowd->getJobs();

// get list of ten jobs from account starting at page 2
$jobs = $crowd->getJobs(2);

// get job by job id
$job = $crowd->getJob($jobId);

创建新作业

// create empty job
$job = $crowd->createJob();

// create job with job info
$job = $crowd->createJob(array(
    "title" => "A brand new job",
    "instructions" => "Follow these rules..."
));

// jobs can also be created from a copy of an existing job
$jobCopy = $crowd->getJob($jobId)->copy();

添加单元

// create units from array
$units = $job->createUnits(array (
  array ("data" => array('column1' => 'value', 'column2' => 'value')),
  array ("data" => array('column1' => 'value2', 'column2' => 'value2'))
));

// units can also be created individually
$unit = $job->createUnit(array('data' => array('column1' => 'value', 'column2' => 'value')));

添加订单

// jobs can create orders
$order = $job->createOrder($numberOfUnits, $channels);

备注

当通过 setAttribute() 方法更新属性时,变更将被跟踪,并且只有这些变更会在更新时发送到 CrowdFlower。

为了正确运行测试,将请求对象作为依赖项传递。