{"id":37007408,"url":"https://github.com/riddle-com/php-client-sdk","last_synced_at":"2026-01-14T00:48:46.316Z","repository":{"id":150670881,"uuid":"581510435","full_name":"riddle-com/php-client-sdk","owner":"riddle-com","description":"A PHP API client written to communicate with the Riddle Creator API v3.","archived":false,"fork":false,"pushed_at":"2023-10-11T14:04:14.000Z","size":38,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-04-13T15:03:29.860Z","etag":null,"topics":["php","sdk-php"],"latest_commit_sha":null,"homepage":"https://www.riddle.com","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/riddle-com.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2022-12-23T11:57:09.000Z","updated_at":"2024-04-13T15:03:29.861Z","dependencies_parsed_at":"2023-10-11T18:15:43.811Z","dependency_job_id":null,"html_url":"https://github.com/riddle-com/php-client-sdk","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/riddle-com/php-client-sdk","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/riddle-com%2Fphp-client-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/riddle-com%2Fphp-client-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/riddle-com%2Fphp-client-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/riddle-com%2Fphp-client-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/riddle-com","download_url":"https://codeload.github.com/riddle-com/php-client-sdk/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/riddle-com%2Fphp-client-sdk/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28406613,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-13T21:51:37.118Z","status":"ssl_error","status_checked_at":"2026-01-13T21:45:14.585Z","response_time":56,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["php","sdk-php"],"created_at":"2026-01-14T00:48:45.724Z","updated_at":"2026-01-14T00:48:46.299Z","avatar_url":"https://github.com/riddle-com.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Riddle PHP client\n\nThis library makes it easy to work with...\n- the Riddle API v3\n- incoming Riddle webhooks (validates \u0026 parses them)\n\nAvailable endpoints can be found [here](https://www.riddle.com/creator/v3/docs).\n\n## Installation\n\nTo use this library you need to have PHP 7.4 or higher (8.0 / 8.1) installed.\n\n### With composer\n\nWhen working with composer all you need to do is run the following command:\n\n```\ncomposer require riddle/client-sdk\n```\n\nIn your .php file you can then include the composer autoloader:\n\n```php\nrequire 'vendor/autoload.php';\n\n// [... your code, e.g. fetching riddles / stats / ...]\n```\n\n### Without composer\n\nTo use it without a package manager download this repository, extract it, keep the `src/` folder and include the `Client.php` file in your project:\n\n```php\nrequire 'riddle-client/src/Client.php';\n\n$client = new Riddle\\Api\\Client('...');\n```\n\n## Authentication\n\nWhen using the API you need to authenticate yourself with an access token. You can create one [in your Riddle account](https://www.riddle.com/creator/account/access-token/) (you must be logged-in to view this page).\nYou can then pass the token to the client:\n\n```php\nrequire 'riddle-client/src/Client.php';\n\n$client = new Riddle\\Api\\Client('access token');\n```\n\nNow you're ready to use the API.\n\n## Example usages\n\n### Get all riddles\n\n```php\nrequire 'riddle-client/src/Client.php';\nrequire 'riddle-client/src/Service/Riddle.php';\n\n$client = new Riddle\\Api\\Client('access token');\n$riddles = $client-\u003eriddle()-\u003elist();\n```\n\n### Get alltime stats for a Riddle (only available for Business \u0026 Enterprise plans)\n\n```php\nrequire 'riddle-client/src/Client.php';\nrequire 'riddle-client/src/Service/Stats.php';\n\n$client = new Riddle\\Api\\Client('access token');\n$riddleStats = $client-\u003estats()-\u003efetchRiddleStats('[RIDDLE_ID]');\n```\n\n### Get riddles from team with tags\n\n```php\nrequire 'riddle-client/src/Client.php';\nrequire 'riddle-client/src/Service/Riddle.php';\n\n$teamId = 123;\n$tagIds = [2]; // to get tag IDs use the tag list endpoint\n$client = new Riddle\\Api\\Client('access token');\n$riddles = $client-\u003eriddle()-\u003elist($teamId, null, $tagIds);\n```\n\n### Parse webhook\n\n```php\nrequire 'riddle-client/src/Webhook/Webhook.php';\n\ntry {\n    $webhook = new Riddle\\Api\\Webhook\\Webhook('WveoGBv11xet392jUwPWbmEbicUn13zR');\n    $payload = $webhook-\u003eparse();\n    \\file_put_contents(__DIR__.'/test-webhook.json', \\json_encode($payload-\u003egetPayload())); // log the webhook payload\n\n    // now work with the payload\n    $resultId = $webhookResponse-\u003egetResultData()['blockId'];\n    // ...\n} catch (\\Throwable $ex) {\n    \\file_put_contents(__DIR__.'/exception.txt', $ex-\u003egetMessage()); // write to a log file in case of an exception\n}\n```\n\n**Note**: The webhook signature key is not required - if it's not given the signature validation will be skipped.\n\n\n### Build basic Riddles\n\nYou can also build Riddles via the API.Please note that this feature is currently in-beta and is expected to be expanded in the future.\n\nPlease drop us any feedback you have on this feature via support chat on [riddle.com](https://www.riddle.com) or send us an email @ [hello@riddle.com](mailto:hello@riddle.com)!\n\n\nTo use this feature, create an instance of either `PollBuilder` or `QuizBuilder`:\n\n```php\nrequire 'riddle-client/src/Client.php';\nrequire 'riddle-client/src/Builder/PollBuilder.php';\n\n$client = new Riddle\\Api\\Client('access token');\n$pollBuilder = new Riddle\\Api\\Builder\\PollBuilder($client);\n```\n\n#### Build a poll\n\nWhen building a poll you can:\n- set the title\n- add single choice questions\n- add multiple choice questions\n- set the single result the user will see at the end of the Riddle\n\nHere's the full code snippet:\n\n```php\nrequire 'riddle-client/src/Client.php';\nrequire 'riddle-client/src/Builder/PollBuilder.php';\n\n$client = new Riddle\\Api\\Client('access token');\n$pollBuilder = new Riddle\\Api\\Builder\\PollBuilder($client);\n\n// configure the poll's settings, such as questions / title / result\n$pollBuilder\n    -\u003esetTitle('My Riddle Title')\n    -\u003eaddSingleChoiceQuestion('What is the answer?', ['Yes', 'No', 'Maybe'])\n    -\u003eaddMultipleChoiceQuestion('What are the answers?', ['Yes', 'No', 'Maybe'])\n    -\u003esetResult('Thanks for participating!', 'We will process your answers accordingly.');\n\n// requests the API and returns the built poll\n$builtPoll = $pollBuilder-\u003ebuild();\n```\n\n#### Build a quiz\n\nWhen building a quiz you can:\n- set the title\n- add single choice questions\n- add multiple choice questions\n- add as many results as you want, each with a title, description and score range (min/max)\n\nHere's the full code snippet:\n\n```php\nrequire 'riddle-client/src/Client.php';\nrequire 'riddle-client/src/Builder/QuizBuilder.php';\n\n$client = new Riddle\\Api\\Client('access token');\n$quizBuilder = new Riddle\\Api\\Builder\\QuizBuilder($client);\n\n// configure the quizz settings, such as questions / title / results\n$quizBuilder\n    -\u003esetTitle('My Riddle Title')\n    -\u003eaddSingleChoiceQuestion('What is the capital of germany?', ['Berlin' =\u003e true, 'Munich' =\u003e false, 'Hamburg' =\u003e false])\n    -\u003eaddMultipleChoiceQuestion('Which words can you use to say \"Hello\" in German?', ['Hallo' =\u003e true, 'Ciao' =\u003e false, 'Guten Tag' =\u003e true])\n    -\u003eaddResult('Not so good', 'You answered most questions incorrectly.', 0, 50)\n    -\u003eaddResult('Well done', 'You answered most questions correctly.', 51, 100);\n\n// requests the API and returns the built quiz\n$builtQuiz = $quizBuilder-\u003ebuild();\n```\n\n**Note:** Generated Riddles will be automatically published. To disable this you must pass `false` to the `build()` method:\n\n```php\n$builtQuiz = $quizBuilder-\u003ebuild(false);\n```\n\n### Building Riddles with custom result pages (buttons, answered blocks etc)\n\n```php\nrequire 'riddle-client/src/Client.php';\nrequire 'riddle-client/src/Builder/PollBuilder.php';\nrequire 'riddle-client/src/Builder/QuizBuilder.php';\n\n$client = new Riddle\\Api\\Client('access token');\n\n// custom result page via the ResultPage class\n$resultPage = (new Riddle\\Api\\Builder\\Objects\\ResultPage())\n    -\u003eaddTextBlock('Thank you for participating in our poll!')\n    -\u003eaddAnsweredBlocks()\n    -\u003eaddMedia('MEDIA_RUL')\n    -\u003eaddSocialShare('Share this poll with your friends!', 'Check out this poll', 'This is a poll about colors')\n    -\u003eaddButton('Go to our website', 'https://www.riddle.com', true)\n;\n\n// Adding it to a quiz\n$quizBuilder = new (new Riddle\\Api\\Builder\\QuizBuilder($client))\n    // - \u003e... // add other questions, form fields, etc\n    -\u003eaddResultPage($resultPage, minPercentage: 0, maxPercentage: 100);\n\n// Adding it to a poll (only one result page possible)\n$pollBuilder = new (new Riddle\\Api\\Builder\\PollBuilder($client))\n    // - \u003e... // add other questions, form fields, etc\n    -\u003esetResultPage($resultPage);\n```\n\n### Build Riddles with forms\n\nYou can add \"Make a form\" blocks to your Riddle. This allows you to collect user data (name, email, phone, etc).\n\n```php\nrequire 'riddle-client/src/Client.php';\nrequire 'riddle-client/src/Builder/QuizBuilder.php';\n\n$client = new Riddle\\Api\\Client('access token');\n\n// custom form field builder via the FormFieldBuilder class\n$formBuilder = (new Riddle\\Api\\Builder\\Objects\\FormFieldBuilder())\n    -\u003esetTitle('Contact us')\n    -\u003eaddNameField('My name field')\n    -\u003eaddEmailField('My email field')\n    -\u003eaddPhoneField('My phone field')\n    -\u003eaddUrlField('My URL field')\n    -\u003eaddNumberField('My number field')\n    -\u003eaddCountryField('My country field')\n    -\u003eaddShortTextField('My short text field')\n    -\u003eaddLongTextField('My long text field');\n\n// Adding it to any builder (poll, quiz, etc)\n$quizBuilder = new (new Riddle\\Api\\Builder\\QuizBuilder($client))\n    // - \u003e... // add other questions, form fields, etc\n    -\u003eaddFormBuilder($formBuilder);\n```\n\n\n### Manipulate the build directly\n\nWe are aware that the current builder classes in this SDK do not cover all possibilities of the builder API (there are just too many!).\n\nTherefore, you can also manipulate the build directly:\n\n```php\n$quizBuilder = new (new Riddle\\Api\\Builder\\QuizBuilder($client));\n\n$rawBuild = $quizBuilder-\u003egetRawBuild();\n$rawBuild['publish']['isShowcaseEnabled'] = false; // advanced option to disable Riddle showcase (only available embedded on customer page)\n\n$quizBuilder-\u003esetRawBuild($rawBuild);\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Friddle-com%2Fphp-client-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Friddle-com%2Fphp-client-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Friddle-com%2Fphp-client-sdk/lists"}