sivi / afd.connectors
一个用于获取ADN消息的连接器库
v2.0.6
2022-04-06 17:01 UTC
Requires
- ext-soap: *
- guzzlehttp/guzzle: ^6.0 || ^7.2
- myclabs/php-enum: ^1.6
- nesbot/carbon: ^2.0
- psr/container: ^1.0 || ^2.0
This package is auto-updated.
Last update: 2024-09-15 04:01:24 UTC
README
当前实现
- TIMEConnector
TIMEConnector
TIMEConnector实现了TIME API。使用此API的前提是您有一个有效的Solera数字护照。
如何使用
实例化需要实现TIMEConfig
接口,您需要提供连接器的配置详细信息。
示例实现
class TIMEConfig implements \SIVI\AFDConnectors\Config\Contracts\TIMEConfig { protected $host; protected $wsdlStoragePath; protected $certificatePath; protected $certificatePassphrase; public function __construct($host, $wsdlStoragePath, $certificatePath, $certificatePassphrase) { $this->host = $host; $this->wsdlStoragePath = $wsdlStoragePath; $this->certificatePath = $certificatePath; $this->certificatePassphrase = $certificatePassphrase; } /** * Get the host of the service * * @return string */ public function getHost() { return $this->host; } /** * The path where the WSDL for the service will be stored. * * This is because the WSDL is not public and needs to be requested with * a client certificate. The PHP SOAP extension does not support * this and that is why a local one must be created. * * @return string */ public function getWSDLStoragePath() { return $this->wsdlStoragePath; } /** * The path where the Solera certificate is stored. * This needs to be a PEM file. * * @return string */ public function getCertificatePath() { return $this->certificatePath; } /** * The passphrase of the Solera certificate. * * @return string */ public function getCertificatePassphrase() { return $this->certificatePassphrase; } }
配置设置完毕后,您就可以获取一些消息了。以下代码将获取TIME的所有未读消息并打印出来。
use SIVI\AFDConnectors\Connectors\TIMEConnector; // Initialize config $config = new TIMEConfig( 'https://www.web.service/sts/portal', '/tmp/', '/path/to/solera/certificate.pem', 'certificate password' ); // Initialize connector $connector = new TIMEConnector($config); // This will return an array of SIVI\AFD\Interfaces\TIME\Message items // which implement the SIVI\AFD\Interfaces\BatchMessage interface. foreach ($connector->getMessage() as $batchMessage) { // This will return an array of SIVI\AFD\Interfaces\TIME\Message items // which implement the SIVI\AFD\Interfaces\Message interface. foreach ($batchMessage->getMessages() as $message) { echo sprintf('TIME Message extension: %s%s', $message->getType(), PHP_EOL); echo sprintf('TIME Message content: %s%s%s', PHP_EOL, $message->getData(), PHP_EOL); } }