apinnecke/oauth-bundle

此包已被弃用且不再维护。没有建议的替代包。

Symfony2 对 lusitanian/oauth 库的包装。


README

oauth-bundle 是一个 symfony 2 的包装包,用于Lusitanian/PHPoAuthLib,该库为 PHP 5.3+ 提供OAuth支持,并且非常容易与其他需要OAuth客户端的项目集成。

Build Status Latest Stable Version Total Downloads

支持的服务

该库支持符合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": {
  "apinnecke/oauth-bundle": "~0.1"
}

使用 composer 安装此包。

$ composer update apinnecke/oauth-bundle

注册包

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

    new \APinnecke\Bundle\OAuthBundle\APinneckeOAuthBundle(),

配置

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

apinnecke_oauth:
    resource_owners:
        Xing:
            client_id: thisismyclientid
            client_secret: thisismyclientsecret

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

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

服务

该包将自动创建服务。在我的例子中,我想使用 xing 服务

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

或将其注入到其他服务中

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

更多用法示例

示例请点击这里