定制 genai/google-form 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

genai/google-form

Composer 安装命令:

composer require genai/google-form

包简介

Submit data to a Google Form from the server: POST to the form's formResponse endpoint, mapping your fields to entry.NNN ids. Best-effort with a short timeout so it never blocks the request (it returns false rather than throwing). curl with a stream fallback. PHP 5.3-safe.

README 文档

README

Submit data to a Google Form from the server — no front-end JS, no Apps Script. POSTs to the form's formResponse endpoint with your fields mapped to entry.NNN ids.

Use

$form = new GenAI\GoogleForm\GoogleForm($formId, array(
    'name'  => 'entry.111111111',
    'email' => 'entry.222222222',
));
$ok = $form->submit(array('name' => 'Linh', 'email' => 'linh@example.com'));

submitRaw(array('entry.111111111' => 'Linh')) bypasses the map. Array values (checkboxes) are sent as repeated keys.

Get the ids

  • formId: the .../forms/d/e/<formId>/viewform segment.
  • entry ids: Form → ⋮ → Get pre-filled link → fill samples → copy; the URL has entry.NNN=... per field.

Config + wiring

[googleform]
form_id = "1FAIpQLSf..."
#[Configuration]
class GoogleFormConfig {
    #[Bean(\GenAI\GoogleForm\GoogleForm::class)]
    public function googleForm(\GenAI\GoogleForm\Bundle\GoogleFormProperty $cfg) {
        return new \GenAI\GoogleForm\GoogleForm($cfg->getFormId(), array(
            'name' => 'entry.111111111', 'email' => 'entry.222222222',
        ));
    }
}

GoogleFormProperty auto-registers (the package declares extra.genai.scan); the field map is form-specific, so it lives in the app's bean.

Behaviour & caveats

  • Best-effort: short timeout (default 5s), and it returns false (never throws) on a network error or an unset form_id — so a failed submit won't break the action that called it (e.g. registration still succeeds).
  • Success isn't strictly verifiable: Google returns 200 even when it silently rejects a submission (missing required field), so true means "sent". Map every required field and confirm once in the form's Responses tab.
  • The form must be public (no login / not "limit to 1 response").
  • It blocks for up to the timeout; lower it, or move the call to a shutdown hook, if you don't want registration to wait.

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2026-07-10

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固