dadeg / php-crowdflower
PHP library for interacting with the Crowdflower API v1
Installs: 3 985
Dependents: 0
Suggesters: 0
Security: 0
Stars: 13
Watchers: 2
Forks: 2
Open Issues: 0
Requires (Dev)
- php-vcr/php-vcr: 1.1.*
- php-vcr/phpunit-testlistener-vcr: 1.1.*
- phpunit/phpunit: 4.1.*
This package is not auto-updated.
Last update: 2025-03-25 04:26:11 UTC
README
There are examples of every method of interacting with the CrowdFlower API in the examples folder. The tests are almost at full coverage. I use this package daily and it has been reliable. In order to run the tests yourself you will need to replace the API key in tests/fixtures with your own API key.
Installation
Add to composer.json
"dadeg/php-crowdflower": "0.1.*"
Update composer for existing projects
composer update dadeg/php-crowdflower
Composer install for new projects
composer install
Getting Started
use CrowdFlower\Account; $crowd = new Account($apiKey);
Getting existing Jobs
// 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);
Creating new Jobs
// 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();
Adding Units
// 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')));
Adding Orders
// jobs can create orders $order = $job->createOrder($numberOfUnits, $channels);
Notes
When attributes are updated via the setAttribute() method, the changes are tracked and only those are sent to CrowdFlower when an update is made.
The Request object is passed as a dependency in order to properly run tests.