mediapart / lapresselibre-bundle
此包已被废弃,不再维护。未建议替代包。
mediapart/lapresselibre 库的 Symfony 扩展包
v2.0.1
2017-11-17 09:12 UTC
Requires
- php: ^5.6|^7.0
- mediapart/lapresselibre: ^2.0
- symfony/options-resolver: ^2.8|^3.3
- symfony/psr-http-message-bridge: ^1.0
- zendframework/zend-diactoros: ^1.4
Requires (Dev)
- phpunit/phpunit: ^5.7|^6.3
- symfony/symfony: ^2.8|^3.3
This package is auto-updated.
Last update: 2023-03-07 13:56:00 UTC
README
安装
使用 Composer 安装此包
composer require mediapart/lapresselibre-bundle
将扩展包载入您的 Kernel
# app/AppKernel.php $bundles = array( // ... new Mediapart\Bundle\LaPresseLibreBundle\MediapartLaPresseLibreBundle(), );
使用您的 LaPresseLibre 合作伙伴凭证 配置您的 App
# app/config/config.yml mediapart_la_presse_libre: public_key: %lapresselibre_publickey% secret_key: %lapresselibre_secretkey% aes_password: %lapresselibre_aespassword% aes_iv: %lapresselibre_aesiv%
Web服务
配置路由
# app/config/routing.yml MediapartLaPresseLibreWebServices: resource: "@MediapartLaPresseLibreBundle/Resources/config/routing/webservices.php" #prefix: lapresselibre/
然后,在 LaPresseLibre 合作伙伴平台 中指定您的端点 URI。
定义您的端点需要做什么。例如,您的 验证端点 将看起来像
<?php # src/Acme/LaPresseLibre/Verification.php namespace AppBundle\LaPresseLibre; use Mediapart\LaPresseLibre\Subscription\Type as SubscriptionType; class Verification { private $public_key; public function __construct($public_key) { $this->public_key = $public_key; } public function alwaysVerifiedAccounts(array $data, $isTesting = false) { $now = new \DateTime('next year'); return [ 'Mail' => $data['Mail'], 'CodeUtilisateur' => $data['CodeUtilisateur'], 'TypeAbonnement' => SubscriptionType::MONTHLY, 'DateExpiration' => $now->format("Y-m-d\TH:i:sO"), 'DateSouscription' => $now->format("Y-m-d\TH:i:sO"), 'AccountExist' => true, 'PartenaireID' => $this->public_key, ]; } }
# app/config/services.yml services: your_verification_service: class: 'AppBundle\LaPresseLibre\Verification' arguments: - '%lapresselibre_publickey%' tags: - { name: 'lapresselibre', route: 'lapresselibre_verification', operation: 'Mediapart\LaPresseLibre\Operation\Verification', method: 'alwaysVerifiedAccounts' }
链接账户
https://github.com/NextINpact/LaPresseLibreSDK/wiki/Liaison-de-compte-utilisateur-par-redirection
配置路由
# app/config/routing.yml MediapartLaPresseLibreLinkAccount: resource: "@MediapartLaPresseLibreBundle/Resources/config/routing/link-account.php" #prefix: lapresselibre/
实现 Mediapart/LaPresseLibre/Account/Repository
和 Mediapart\Bundle\LaPresseLibreBundle\Account\AccountProvider
接口。
# app/config/services.yml services: # … your_account_repository: class: 'AppBundle\LaPresseLibre\AccountRepository' your_account_provider: class: 'AppBundle\LaPresseLibre\AccountProvider'
更新配置
# app/config/config.yml mediapart_lapresselibre: # … account: repository: 'your_account_repository' provider: 'your_account_provider'