承接 jackbutler/php-linkedin 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

jackbutler/php-linkedin

Composer 安装命令:

composer require jackbutler/php-linkedin

包简介

A PHP library for interacting with the LinkedIn API

README 文档

README

A PHP library to provide easy interaction with the LinkedIn API

Installation

Install this package via composer:

Run composer require jackbutler/php-linkedin

Install manually:

Download this package into your project and include using:

    <?php
        require 'path/to/LinkedIn/autoload.php';

Usage

Before carrying out calls to the API, your application should first be authenticated by the user to interact with LinkedIn, namely by having them grant you an authorisation code, which you can then exchange for a longer-lived access token (currently 60 days). The process recommended is as follows:

  1. Sign In with LinkedIn

    The library includes a method for generating sign in URLs to provide a "Sign In with LinkedIn" button/link to your users. To generate this URL, you first need to create a new instance of the LinkedIn class:

     <?php
       $args = array (
                 'clientId'      => 'client_id',          // Your LinkedIn API Client Id (required)
                 'clientSecret'  => 'client_secret',      // Your LinkedIn API Client Secret (required)
                 'callback'  => 'URL/to/callback'         // The absolute URL to your application's callback handler (required for auth requests)
            );
    
       $linkedin = new PHPLI\Linkedin($args);

    You can then use this instance to generate a login URL, for your required scope. For example:

    <?php
       $scope = array (
           "r_basicprofile",
           "r_emailaddress"
                  );
       $signinUrl = $linkedin->getLoginURL($scope);

    You can then provide this URL to your users to sign in with LinkedIn:

  2. Exchange Authorisation Token for Access Token

    Step 1 will take user through the sign in and authorisation process on LinkedIn, and will then return your user to the callback URL you provided, with an authorisation token (assuming all went well). In you callback script you then need to exchange the short-lived authorisation token for a longer-lived access token (currently 60 days).

    The library provides a login handler that can be used inside your callback script as follows:

    <?php
       // Instantiate a LinkedIn object as step 1, then:
    
       $token = $linkedin->handleLogin();

    This method will attempt to retrieve the auth code and CSRF token from the URL query string (via $_GET), then internally calls the getAccessToken() method to carry out the exchange. As well as returning the access token, the token is also saved as a property of the LinkedIn object (during the getAccessToken() call) to prepare the object for subsequent requests. The access token will be stored in the object for the lifetime of that instance, so your application will need to store the access token if you wish to use it for later requests.

  3. Make requests to the API

    To make requests to the API you will again need an instance of PHPLI\LinkedIn, but this time with an access token also set during instantiation:

     <?php
       $args = array (
                 'clientId'      => 'client_id',          // Your LinkedIn API Client Id (required)
                 'clientSecret'  => 'client_secret',      // Your LinkedIn API Client Secret (required)
                 'accessToken'  => 'the_access_token'     // The access token authorised to make requests on the user's behalf
            );
    
       $linkedin = new PHPLI\Linkedin($args);

    Once you have the instance of LinkedIn, you can then use the request() method to carry out your request. The arguments of request() are as follows:

       <?php
           request(
               String resource,
               String method = "GET",
               Array data = []
           );

    The following gives an example of getting a few attributes of the logged in user from LinkedIn

        <?php
            $response = $linkedin->request("/people/~:(first-name,last-name,id,email-address)");

Development

This library I developed as part of another project I was working on, but as I struggled myself to find a suitable library to interact with LinkedIn, I thought I'd extract it and package it for others to use. I do plan on maintaining it and improving it, I'd like to add some helper classes, such as a LinkedInUser class (if anyone has used the Facebook PHP SDK, I'd like to build this into something similar).

Please feel free to fork this project, submit pull requests for improvements etc.

License

This project is licensed under the MIT License.

jackbutler/php-linkedin 适用场景与选型建议

jackbutler/php-linkedin 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 32.47k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2016 年 05 月 28 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 jackbutler/php-linkedin 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 jackbutler/php-linkedin 我们能提供哪些服务?
定制开发 / 二次开发

基于 jackbutler/php-linkedin 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 32.47k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 5
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 0
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-05-28