Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/xperseguers/doodle_client
This library provides a missing feature of Doodle (https://doodle.com): an API in PHP to programmatically access and create polls on the Doodle platform.
https://github.com/xperseguers/doodle_client
Last synced: 3 months ago
JSON representation
This library provides a missing feature of Doodle (https://doodle.com): an API in PHP to programmatically access and create polls on the Doodle platform.
- Host: GitHub
- URL: https://github.com/xperseguers/doodle_client
- Owner: xperseguers
- License: gpl-3.0
- Created: 2015-09-25T21:52:41.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2019-10-30T11:09:26.000Z (about 5 years ago)
- Last Synced: 2024-10-03T10:53:33.452Z (4 months ago)
- Language: PHP
- Homepage:
- Size: 68.4 KB
- Stars: 15
- Watchers: 8
- Forks: 6
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Doodle Client
This library provides a missing feature of Doodle (https://doodle.com): an API to programmatically access and create
polls on the Doodle platform.I was surprised to find only a basic API to *initiate* polls (not actually creating them, just pre-filling the form) but
not anything else to fetch the list of polls or related participant answers so I contacted them and got this answer on
September 25th, 2015:> Unfortunately, Doodle won't be offering an API any longer.
>
> -- KatharinaAs such I wrote this PHP client.
## Basic Usage
```
$doodleUsername = '[email protected]';
$doodlePassword = 'my-very-secret-password';$client = new \Causal\DoodleClient\Client($doodleUsername, $doodlePassword);
$client->connect();$myPolls = $client->getPersonalPolls();
echo '
My polls
';
echo '
- ';
- ';
echo '' . htmlspecialchars($poll->getTitle()) . '';
echo '' . nl2br($poll->getDescription()) . '
';
echo 'Export answers as: ' .
'Excel | ' .
'PDF';
echo ' ';
foreach ($myPolls as $poll) {
echo '
}
echo '
// Optional, if you want to prevent actually authenticating over and over again
// with future requests (thus reusing the local authentication cookies)
$client->disconnect();
```
## Create a Poll (Text Options)
```
$newPoll = $client->createPoll([
'type' => 'text',
'title' => 'Dinner',
'location' => 'Restaurant Xtra',
'description' => 'I suggest we meet and have a nice time together',
'name' => 'John Doo',
'email' => '[email protected]',
'options' => [
'Lasagna',
'Pizza',
'Meat',
],
]);
echo 'link to new poll: ' . $newPoll->getPublicUrl();
```
## Create a Poll (Dates)
```
$newPoll = $client->createPoll([
'type' => 'date',
'title' => 'Dinner',
'location' => 'Restaurant Xtra',
'description' => 'I suggest we meet and have a nice time together',
'name' => 'John Doo',
'email' => '[email protected]',
'dates' => [
'20150929' => ['1930', '2000'],
'20150930' => ['2000'],
'20151030' => ['1945', '2000'],
],
]);
echo 'link to new poll: ' . $newPoll->getPublicUrl();
```
## Invite participants
```
// Selection of a given poll could be based on any "$poll" from the
// foreach loop in "Basic Usage" example or of course "$newPoll".
$emailAdresses = [
'[email protected]',
'[email protected]',
];
$message = 'Hey there! Please check this doodle!';
$client->inviteParticipants($poll, $emailAddresses, $message);
```
## Delete a Poll
```
// Selection of a given poll could be based on any "$poll" from the
// foreach loop in "Basic Usage" example.
$client->deletePoll($poll);
```
## Table of Answers
Another example of use, would be to fetch answers for a given poll.
```
// Selection of a given poll could be based on any "$poll" from the
// foreach loop in "Basic Usage" example.
echo '';
echo '';
echo '';
echo '';
$options = $poll->getOptions();
foreach ($options as $option) {
echo '' . htmlspecialchars($option) . '';
}
echo '';
echo '';
echo '';
$participants = $poll->getParticipants();
foreach ($participants as $participant) {
echo '';
echo '' . htmlspecialchars($participant->getName()) . '';
foreach ($participant->getPreferences() as $preference) {
switch ($preference) {
case '0':
$value = 'NO';
$color = '#ffccca';
break;
case '1':
$value = 'YES';
$color = '#d1f3d1';
break;
case '2':
$value = 'If needed';
$color = '#ffeda1';
break;
default:
$value = '?';
$color = '#eaeaea';
break;
}
echo '' . htmlspecialchars($value) . '';
}
echo '';
}
echo '';
echo '';
```