happyr/linkedin-bundle

一个用于 happyr/linkedin-api-client 的 symfony 扩展包

安装数: 38,774

依赖: 0

建议者: 0

安全性: 0

星标: 8

关注者: 4

分支: 5

公开问题: 2

类型:symfony-bundle

1.0.0 2018-02-04 17:19 UTC

This package is auto-updated.

Last update: 2024-08-25 07:00:04 UTC


README

这是一个非常小巧的扩展包,用于注册 LinkedIn 客户端的服务。

简单安装

为了方便安装所有组件,您可以运行以下 Composer 命令

composer require php-http/curl-client guzzlehttp/psr7 php-http/message happyr/linkedin-bundle

然后将 LinkedInBundle 添加到您的 AppKernel 中。

// app/AppKernel.php
class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            // ...
            new Happyr\LinkedInBundle\HappyrLinkedInBundle()
        );
    }
}

可选

如果您希望进行出色的调试和更简单的设置,您可能需要安装 HTTPlugBundle

composer require php-http/httplug-bundle

然后确保您已经在 AppKernel 中添加了 HttplugBundle 和 LinkedInBundle。

// app/AppKernel.php
class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            // ...
            new Http\HttplugBundle\HttplugBundle(),
            new Happyr\LinkedInBundle\HappyrLinkedInBundle()
        );
    }
}

为什么安装这么多包?

请参阅LinkedIn 客户端(安装)或 HTTPlug 文档中的安装说明。

使用方法

happyr_linkedin:
  app_id: 'xxx'
  app_secret: 'yyy'
  request_format: 'json' # Default
  response_format: 'array' # Default
  http_client: 'httplug.client' # Service ID for an object implementing Http\Client\HttpClient 
  http_message_factory: 'httplug.message_factory' # Service ID for an object implementing Http\Message\MessageFactory
$linkedin = $this->get('happyr.linkedin');
$user = $linkedin->get('v1/people/~:(firstName,lastName)');

更多信息请查看库仓库: https://github.com/Happyr/LinkedIn-API-client

身份验证

实现 LinkedIn 身份验证最简单的方法是使用 Symfony 的 Guard 组件。