1. Go to this page and download the library: Download riddle/client-sdk library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
riddle / client-sdk example snippets
// [... your code, e.g. fetching riddles / stats / ...]
$client = new Riddle\Api\Client('...');
$client = new Riddle\Api\Client('access token');
$client = new Riddle\Api\Client('access token');
$riddles = $client->riddle()->list();
$client = new Riddle\Api\Client('access token');
$riddleStats = $client->stats()->fetchRiddleStats('[RIDDLE_ID]');
$teamId = 123;
$tagIds = [2]; // to get tag IDs use the tag list endpoint
$client = new Riddle\Api\Client('access token');
$riddles = $client->riddle()->list($teamId, null, $tagIds);
try {
$webhook = new Riddle\Api\Webhook\Webhook('WveoGBv11xet392jUwPWbmEbicUn13zR');
$payload = $webhook->parse();
\file_put_contents(__DIR__.'/test-webhook.json', \json_encode($payload->getPayload())); // log the webhook payload
// now work with the payload
$resultId = $webhookResponse->getResultData()['blockId'];
// ...
} catch (\Throwable $ex) {
\file_put_contents(__DIR__.'/exception.txt', $ex->getMessage()); // write to a log file in case of an exception
}
$client = new Riddle\Api\Client('access token');
$pollBuilder = new Riddle\Api\Builder\PollBuilder($client);
$client = new Riddle\Api\Client('access token');
$pollBuilder = new Riddle\Api\Builder\PollBuilder($client);
// configure the poll's settings, such as questions / title / result
$pollBuilder
->setTitle('My Riddle Title')
->addSingleChoiceQuestion('What is the answer?', ['Yes', 'No', 'Maybe'])
->addMultipleChoiceQuestion('What are the answers?', ['Yes', 'No', 'Maybe'])
->setResult('Thanks for participating!', 'We will process your answers accordingly.');
// requests the API and returns the built poll
$builtPoll = $pollBuilder->build();
$client = new Riddle\Api\Client('access token');
$quizBuilder = new Riddle\Api\Builder\QuizBuilder($client);
// configure the quizz settings, such as questions / title / results
$quizBuilder
->setTitle('My Riddle Title')
->addSingleChoiceQuestion('What is the capital of germany?', ['Berlin' => true, 'Munich' => false, 'Hamburg' => false])
->addMultipleChoiceQuestion('Which words can you use to say "Hello" in German?', ['Hallo' => true, 'Ciao' => false, 'Guten Tag' => true])
->addResult('Not so good', 'You answered most questions incorrectly.', 0, 50)
->addResult('Well done', 'You answered most questions correctly.', 51, 100);
// requests the API and returns the built quiz
$builtQuiz = $quizBuilder->build();
$builtQuiz = $quizBuilder->build(false);
$client = new Riddle\Api\Client('access token');
// custom result page via the ResultPage class
$resultPage = (new Riddle\Api\Builder\Objects\ResultPage())
->addTextBlock('Thank you for participating in our poll!')
->addAnsweredBlocks()
->addMedia('MEDIA_RUL')
->addSocialShare('Share this poll with your friends!', 'Check out this poll', 'This is a poll about colors')
->addButton('Go to our website', 'https://www.riddle.com', true)
;
// Adding it to a quiz
$quizBuilder = new (new Riddle\Api\Builder\QuizBuilder($client))
// - >... // add other questions, form fields, etc
->addResultPage($resultPage, minPercentage: 0, maxPercentage: 100);
// Adding it to a poll (only one result page possible)
$pollBuilder = new (new Riddle\Api\Builder\PollBuilder($client))
// - >... // add other questions, form fields, etc
->setResultPage($resultPage);
$client = new Riddle\Api\Client('access token');
// custom form field builder via the FormFieldBuilder class
$formBuilder = (new Riddle\Api\Builder\Objects\FormFieldBuilder())
->setTitle('Contact us')
->addNameField('My name field')
->addEmailField('My email field')
->addPhoneField('My phone field')
->addUrlField('My URL field')
->addNumberField('My number field')
->addCountryField('My country field')
->addShortTextField('My short text field')
->addLongTextField('My long text field');
// Adding it to any builder (poll, quiz, etc)
$quizBuilder = new (new Riddle\Api\Builder\QuizBuilder($client))
// - >... // add other questions, form fields, etc
->addFormBuilder($formBuilder);
$quizBuilder = new (new Riddle\Api\Builder\QuizBuilder($client));
$rawBuild = $quizBuilder->getRawBuild();
$rawBuild['publish']['isShowcaseEnabled'] = false; // advanced option to disable Riddle showcase (only available embedded on customer page)
$quizBuilder->setRawBuild($rawBuild);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.