wandi/oauth-bundle

Symfony3 对 lusitanian/oauth 库的包装。

1.2.0 2019-02-22 09:44 UTC

This package is auto-updated.

Last update: 2024-09-23 01:26:35 UTC


README

OAuthBundle 是一个用于 Lusitanian/PHPoAuthLib 的 symfony 3 包装扩展包,它为 PHP 5.3+ 提供了 OAuth 支持,并且很容易与任何需要 OAuth 客户端的任何项目集成。

支持的服务

该库支持 OAuth 1.x 和 OAuth 2.0 兼容的服务。下面列出了目前实现的服务列表。更多服务将很快实现。

包含的服务实现

  • OAuth1
    • BitBucket
    • Etsy
    • FitBit
    • Flickr
    • Scoop.it!
    • Tumblr
    • Twitter
    • Xing
    • Yahoo
  • OAuth2
    • Amazon
    • BitLy
    • Box
    • Dailymotion
    • Dropbox
    • Facebook
    • Foursquare
    • GitHub
    • Google
    • Harvest
    • Heroku
    • Instagram
    • LinkedIn
    • Mailchimp
    • Microsoft
    • PayPal
    • Pocket
    • Reddit
    • RunKeeper
    • SoundCloud
    • Vkontakte
    • Yammer
  • 更多即将到来!

要了解更多关于 Lusitanian/PHPoAuthLib 的信息,请访问 这里

安装

将 oauth-bundle 添加到您的 composer.json 文件中

"require": {
  "wandi/oauth-bundle": "~0.1"
}

使用 composer 安装此包。

$ composer update wandi/oauth-bundle

注册扩展包

在您的 app/AppKernel.php 中注册扩展包

    new \Wandi\OAuthBundle\WandiOAuthBundle(),

配置

现在将所需的配置添加到 app/config/config.yml

wandi_oauth:
    resource_owners:
        Xing:
            client_id: thisismyclientid
            client_secret: thisismyclientsecret

重要:资源所有者的名称必须使用正确的大小写。请查看 ServiceFactory/ResourceOwners.php 中的可用常量。

这里以 Xing 为例。将其替换为您想要的任何名称。现在添加您需要的所有资源所有者,服务将自动创建。

服务

此扩展包将自动创建服务。在我的例子中,我想要 xing 服务

    $service = $this->container->get('wandi_oauth.service.xing');

或将其注入到另一个服务中

    fancy_company.random_namespace.wayne_bundle:
        class: FancyCompany\Bundle\WayneBundle\MyCool\ClassFor\WorldDominance
        arguments:
            - "@wandi_oauth.service.xing"

更多使用示例

如何使用 Lusitanian/PHPoAuthLib 这里