liesauer / ql-plugin-simpleform
QueryList 插件 - SimpleForm
v4.0.1
2017-10-03 04:33 UTC
Requires
- jaeger/querylist: ^4.0.0
- jaeger/querylist-absolute-url: ^4.0.0
This package is auto-updated.
Last update: 2024-09-05 19:22:10 UTC
README
使表单提交更容易
安装
composer require liesauer/ql-plugin-simpleform
绑定
- QueryList
simpleForm
($formUrl, $formSelector = '', $formParams = [], $postParams = [], ...$args)formUrl
获取表单的位置formSelector
如果有多个表单元素则必须formParams
用于获取表单,读取QueryList::get
或QueryList::post
,默认方法是 getpostParams
与formParams
相同,但用于表单提交,默认方法是 postargs
未使用
用法
use liesauer\QLPlugin\SimpleForm; use QL\QueryList; require_once __DIR__ . '/vendor/autoload.php'; // cookie needed for this example $cookie = new \GuzzleHttp\Cookie\CookieJar(); $ql = QueryList::getInstance(); // use this plugin $ql->use(SimpleForm::class); $username = $ql->simpleForm('https://github.com/login', '', [ 'options' => [ 'verify' => false, 'cookies' => $cookie, ], ], [ 'params' => [ 'login' => 'username', 'password' => 'password', ], 'options' => [ 'verify' => false, 'cookies' => $cookie, ], ])->find('.header-nav-current-user>.css-truncate-target')->text(); if (!empty($username)) { echo "welcome back, {$username}!\n"; } else { $error = $ql->find('.flash-error>.container')->text(); echo "{$error}\n"; }