buuum/typeform

简单的Typeform API

v1.0.2 2017-09-12 07:16 UTC

This package is auto-updated.

Last update: 2024-09-17 19:44:19 UTC


README

Packagist license

简单且极灵活的PHP事件类

入门

使用Buuum需要PHP >= 5.5。

安装

系统需求

使用Buuum\Typeform需要PHP >= 5.5.0,但推荐使用最新的稳定版PHP。

Composer

Buuum可在Packagist上获取,并使用Composer进行安装

composer require buuum/typeform

手动安装

只要遵循PSR-0或PSR-4标准,您可以使用自己的自动加载器。只需将src目录的内容放入您的vendor目录中。

方法

getForm

$typeform = new Typeform($api_key);
$response = $typeform->getForm($token_form);

response

array(3) {
  ["stats"]=> array(3) {
    ["showing"]=> int(1)
    ["total"]=> int(48)
    ["completed"]=> int(27)
  }
  ["questions"]=> array(9) {
    [0]=> array(3) {
      ["id"]=>
      string(20) "list_24762704_choice"
      ["question"]=>
      string(4) "test"
      ["field_id"]=>
      int(24762704)
    }
    ... 
  }
  ["responses"]=>
    array(5) {
      ["completed"]=>
      string(1) "1"
      ["token"]=>
      string(32) "bdc6d79bbf141af6b119f7bffde31bcb"
      ["metadata"]=>
      array(7) {
        ["browser"]=>
        string(7) "default"
        ["platform"]=>
        string(5) "other"
        ["date_land"]=>
        string(19) "2016-11-30 16:30:28"
        ["date_submit"]=>
        string(19) "2016-11-30 16:30:38"
        ["user_agent"]=>
        string(120) "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.98 Safari/537.36"
        ["referer"]=>
        string(59) "https://kuvut1.typeform.com/to/A7moU3?hash=dsfsdf&quiz=3243"
        ["network_id"]=>
        string(10) "11ab630aa4"
      }
      ["hidden"]=>
      array(2) {
        ["hash"]=>
        string(6) "dsfsdf"
        ["quiz"]=>
        string(4) "3243"
      }
      ["answers"]=>
      array(6) {
        ["list_24762704_choice"]=>
        string(1) "1"
        ["yesno_24736784"]=>
        string(1) "0"
        ["list_24817134_choice"]=>
        string(2) "r2"
        ["list_24817136_choice"]=>
        string(2) "r2"
        ["number_24818069"]=>
        string(3) "423"
        ["score"]=>
        string(1) "3"
      }
    }
    

getForms

$typeform = new Typeform($api_key, $url_typeform);
$typeform->getForms();

$typeform->getStats();
$typeform->getQuestions();
$typeform->getResponses();

getAllForms

$typeform = new Typeform($api_key, $url_typeform);
$typeform->getAllForms();

$typeform->getStats();
$typeform->getQuestions();
$typeform->getResponses();

formatDataByExport

$typeform = new Typeform($api_key, $url_typeform);
$typeform->getAllForms();

$data = $typeform->formatDataByExport();

$fp = fopen('excel.csv', 'w');
fputcsv($fp, $data['headers'], "\t");
foreach ($data['rows'] as $row) {
    fputcsv($fp, $row, "\t");
}
fclose($fp);

getNextPage, getPrevPage

$typeform->getNextPage();
$typeform->getPrevPage();

设置器

$typeform->setLimit(10);
$typeform->setApiKey($api_key);
$typeform->setApiUri($api_uri);
$typeform->setFormId($formId);
$typeform->setFormIdFromUrl($url_typeform);
$typeform->setPage($page);
$typeform->setCompleted($completed);
$typeform->setSince($since);
$typeform->setUntil($until);

与webhook协同工作

webhook.php

try{
    $typeform = new Typeform($api_key);
    $response = $typeform->getPayLoad();
 }catch(Exception $e){
    echo $e->getMessage();
}

response

array(
    'hiddens' => array(
        'hash' => ''
     ),
    'score'   => 43,
    'token'   => '4234324234332ewfwer3r2rfe'
);

许可协议

MIT许可协议 (MIT)

版权所有 (c) 2016 alfonsmartinez

特此授予任何人免费获取此软件及其相关文档文件(“软件”)的副本的权利,无需限制地处理该软件,包括但不限于使用、复制、修改、合并、发布、分发、再许可和/或销售软件的副本,并允许将软件提供给获得软件的人使用,但需遵守以下条件

上述版权声明和本许可协议应包含在软件的所有副本或主要部分中。

本软件按“现状”提供,不提供任何类型的保证,无论是明示的还是暗示的,包括但不限于适销性、特定用途的适用性和非侵权性。在任何情况下,作者或版权所有者均不对任何索赔、损害或其他责任承担责任,无论这些责任是由于合同、侵权或其他方式引起的,无论这些责任是否与软件或软件的使用或其他方式有关。