phillipsdata/linkedin
Composer 安装命令:
composer require phillipsdata/linkedin
包简介
PHP LinkedIn SDK
关键字:
README 文档
README
This library allows you to communicate with the LinkedIn APIs. It is very generic and depends on the user to know their target endpoints and the data to be submitted.
Installation
Install via composer:
composer require phillipsdata/linkedin
Usage
To start, instantiate the class
$linkedin = new LinkedIn( 'LINKEDIN_API_KEY', 'LINKEDIN_API_SECRET', 'LINKEDIN_CALLBACK_URL' );
Get a URL to visit and be granted permissions from
$permissions_url = $linkedin->getPermissionUrl( array( 'r_basicprofile', 'r_liteprofile', 'w_share', 'w_member_social' ) );
The parameter here is a list of 'scopes'. If granted, they determine which API calls you are authorized to make.
API v1 Permissions
- r_basicprofile
- r_emailaddress
- w_share
- rw_company_admin
API v2 Permissions
- r_liteprofile (replaces r_basicprofile)
- r_emailaddress
- w_member_social (replaces w_share)
After visiting the $permission_url, you will be redirected to the 'LINKEDIN_CALLBACK_URL' you submitted to the constructor. The redirect will submit a 'code' get parameter to that location which can be used to generate an access token that will be used to grant permission for future API calls.
$tokenResponse = $linkedin->getAccessToken($_GET['code']); if ($tokenResponse->status() == 200) { // Record $tokenResponse->response() in some way } else { echo $tokenResponse->errors(); }
This will return the access token if you want to store it somehow. Additionally it will set the token on your current LinkedIn object which will use it for any API calls you make.
After this you can make any api call you like as long you know the endpoint and data required
See the docs here for a full description of making a share request
$data = [ 'author' => 'urn:li:person:123456', 'lifecycleState' => 'PUBLISHED', 'specificContent' => [ 'com.linkedin.ugc.ShareContent' => [ 'shareCommentary' => [ 'text' => "Leverage LinkedIn's APIs to maximize engagement" ], 'shareMediaCategory' => 'NONE' ] ], 'visibility' => ['com.linkedin.ugc.MemberNetworkVisibility' => 'PUBLIC'] ]; $shareResponse = $linkedin->post('v2/ugcPosts', $data);
The response is returned as an LinkedInAPIResponse object that can be accessed like this
$shareResponse->headers(); // An array of header fields and their values $shareResponse->raw(); // Exactly what was returned by LinkedIn, including headers $shareResponse->response(); // An object containing the data returned by LinkedIn $shareResponse->errors(); // Any errors given in the response $shareResponse->status(); // The status code returned by the request
The API also has a method called share() which takes a bit of work off of the user by formatting the data how LinkedIn expects.
This method worked different pre v2.x. Instead it used version 1 of the LinkedIn api and simply defaulted the endpoint.
$shareResponse = $linkedin->share('Leverage LinkedIn's APIs to maximize engagement');
or
$shareResponse = $linkedin->share( 'Leverage LinkedIn's APIs to maximize engagement', [ 'urn' => 'urn:li:digitalmediaAsset:C5422AQEbc381YmIuvg', 'type' => 'IMAGE', 'title' => 'LinkedIn API', 'description' => 'Shows how great the LinkedIn API is.' ], 'CONNECTIONS' );
phillipsdata/linkedin 适用场景与选型建议
phillipsdata/linkedin 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 245 次下载、GitHub Stars 达 3, 最近一次更新时间为 2019 年 01 月 04 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「rest」 「api」 「linkedin」 「api client」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 phillipsdata/linkedin 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 phillipsdata/linkedin 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 phillipsdata/linkedin 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Linkedin API integration for Laravel and Lumen 5
LinkedIn API PHP SDK with OAuth 2.0 & CSRF support. Can be used for social sign in or sharing on LinkedIn. Examples. Documentation.
LinkedIn integration for Social
LinkedIn API PHP SDK with OAuth 2.0 & CSRF support. Can be used for social sign in or sharing on LinkedIn. Examples. Documentation.
A PSR-7 compatible library for making CRUD API endpoints
Api bundle
统计信息
- 总下载量: 245
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-01-04