mrdth/decipher-api
最新稳定版本:1.1.1
Composer 安装命令:
composer require mrdth/decipher-api
包简介
PHP Wrapper for the FocusVision Decipher REST Api
README 文档
README
This package provides a PHP wrapper for the FocusVision Decipher API, along with binding for using it in Laravel applications.
Installation
Install with composer:
composer require mrdth/decipher-api
Usage In Laravel
Add two new env vars:
- DECIPHER_API_URI_BASE - base URI for the decipher api (E.g. https://v2.decipherinc.com/api/v1/)
- DECIPHER_API_KEY - API key for the application
The package will be auto-registered, and can be accessed via it's facade.
All calls to the API via the wrapper should be carried out inside a try - catch block; The wrapper does not deal with any Exceptions thrown by the underlying Guzzle client.
$directory = 'selfserve/99d'; $survey_id = '12345'; \Decipher::setServerDirectory($directory)->setSurveyId($survey_id); try { $survey_structure = \Decipher::getSurveyStructure('json'); // Do whatever with $survey object } catch (\GuzzleHttp\Exception\RequestException $e) { echo 'Error making request, server responded: ' . $e->getCode(); }
Usage as a standalone PHP Package
use MrDth\DecipherApi\Factories\Client; use MrDth\DecipherApi\Decipher; $api_uri = 'https://v2.decipherinc.com/api/v1/'; $api_key = 'OBVIOUSLYFAKEAPIKEY'; $directory = 'selfserve/99d'; $survey_id = '12345'; $client = new Client($api_uri, $api_key); $decipher = new Decipher($client, $api_uri, $api_key);
All calls to the API via the wrapper should be carried out inside a try - catch block; The wrapper does not deal with any Exceptions thrown by the underlying Guzzle client.
$decipher->setServerDirectory($directory)->setSurveyId($survey_id); try { $survey_structure = $decipher->getSurveyStructure('json'); // Do whatever with $survey object } catch (\GuzzleHttp\Exception\RequestException $e) { echo 'Error making request, server responded: ' . $e->getCode(); }
Methods exposed via the wrapper
- getSurveyList() - Get a list of all surveys available with the current API key.
- setServerDirectory(string $directory) - Directory where your projects are stored on the decipher server
- setSurveyId(int $id) - Set the ID of the current survey to work with.
- setCondition(string $condition) - Condition required to retrieve the participant. This is a Python condition as if you would enter in survey logic or crosstabs. For example, “qualified and q3.r2” retrieves only participants that were qualified and answered q3 as r2.
- getSurveyStructure(string $format) - Retrieve the structure of available questions for a survey, returning htem in the specified format. Valid formats are: html, json, text, tab
- getSurveyData(array $fields = ['all'], string $format = 'json') - Retrieve the responses to the question IDs passed in $fields from Decipher. Note: uuid & status fields will always be returned. Any condition set using ::setCondition() will be applied
- getSurveyFile(string $filename) - Retrieve the survey file called $filename as a string.
mrdth/decipher-api 适用场景与选型建议
mrdth/decipher-api 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 745 次下载、GitHub Stars 达 0, 最近一次更新时间为 2019 年 11 月 17 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 mrdth/decipher-api 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 mrdth/decipher-api 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 745
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 21
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-11-17