olegkhuss / verilocationsoapbundle
verilocation soap 客户端的 Symfony2 扩展包
0.3.0
2016-03-30 10:13 UTC
Requires
- olegkhuss/verilocationsoap: ~0.1.0@dev
- symfony/framework-bundle: ~2.1|~3.0
This package is auto-updated.
Last update: 2024-09-23 02:14:12 UTC
README
示例用法
在 composer.json 中包含
{
.....
"require": {
"olegkhuss/verilocationsoapbundle": "~0.2@dev"
}
}
config.yml
gelo_verilocation_soap:
auto_logon: false
username: <username>
password: <password>
wsdl: 'http://www.verilocation.com/gps/xml/version_001.asmx?wsdl'
# SoapClient options see https://php.ac.cn/manual/ru/soapclient.soapclient.php
# options: ~
PHP 代码
<?php
// ...
public function indexAction(Request $request)
{
$client = $this->get('gelo_verilocation_soap.client');
try {
$client->doLogon(
$this->container->getParameter('gelo_verilocation_soap.client.username'),
$this->container->getParameter('gelo_verilocation_soap.client.password')
);
// is webservice active?
print_r($client->isWebserviceActive());
// get all vehicles
print_r($client->getVehicles());
// get all vehicles extended
print_r($client->getVehiclesExt());
// get all latest positions
print_r($client->getLocationsLatest());
} catch (\Exception $e) {
// could not login, check username/password
throw $e;
}
}
如果 `auto_logon: true`,则避免手动调用 doLogon
<?php
public function indexAction(Request $request)
{
try {
$client = $this->get('gelo_verilocation_soap.client');
// is webservice active?
print_r($client->isWebserviceActive());
// ...
} catch (\Exception $e) {
// could not login, check username/password
throw $e;
}
}