native-network/social_json_api
Composer 安装命令:
composer require native-network/social_json_api
包简介
This module enables a JSON API for your Open Social site.
README 文档
README
Social JSON API provides an API which can be used with the following entities:
- comment
- event_enrollment
- file
- group
- group_content
- node
- post
- profile
- taxonomy_term
- user
It works out of the box for these entities. However you'll need to do some configuration to access the API (authentication and authorization).
Installation
- Enable this module and all its dependencies.
- The module will automatically create a folder outside your docroot (web/html) directory where you can store the public and private key combination. By default this is:
private://oauth_api_keys/. - If your site has a sitemanager role it will automatically assign a bunch of permissions to this role.
- Check if all the right entities are enabled in social_json_api_entity_type_alter().
Configuration
The API System which is implemented has multiple authentication grants available. These are all allowed in Open Social by default.
To determine which grant is applicable for your use-case please read the oauth2 documentation For demo purposes we assume you'll want the password grant, which means that you'll login with account details of a given user.
- Go to /admin/config/people/simple_oauth and configure the OAuth settings to your needs. Double check the expiration times and if the keys exist. During development you can set the access token expiration time on a higher value. Usually this should be below 300 seconds.
- Create a consumer on /admin/config/services/consumer/add
- Fill in at least:
- Label: The label for your consumer (e.g. My CRM system)
- User: leave this empty
- New secret: Generate a secure string here (e.g. using Lastpass, but do remember this, you'll need this later)
- Is confidential: yes
- Is this consumer 3rd party?: yes
- Redirect URL: leave empty
- Scopes: select the roles you want to use here, e.g. Sitemanager (this determines the permissions for the API)
- After saving the consumer you'll go to the consumer overview where you can see the consumer uuid.
Authentication
Now you can get access to the API by doing a POST Request on /oauth/token with the following body:
grant_type:password
client_id:uuid
client_secret:secret
username:test
password:test
Just fill in the client_id, client_secret, username and password accordingly. You will receive an access_token and refresh_token which you can use in subsequent requests, e.g. in refresh_token requests or you can use the same access_token during the expire time.
More info here: http://oauth2.thephpleague.com/authorization-server/resource-owner-password-credentials-grant/
Documentation
Some more information is available on your site on:
/admin/config/opensocial/social-json-api
You will also find a link to the documentation for your API there. The documentation is automatically generated and displayed with ReDoc.
native-network/social_json_api 适用场景与选型建议
native-network/social_json_api 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 4 次下载、GitHub Stars 达 0, 最近一次更新时间为 2019 年 06 月 14 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「json」 「api」 「drupal」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 native-network/social_json_api 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 native-network/social_json_api 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 native-network/social_json_api 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Kinikit - PHP Application development framework MVC component
Provides an add-on purchasable entity.
Drupal integration module for the Kalastatic prototyping and styleguide tool
ext-json wrapper with sane defaults
Provides a base set of configuration and module dependencies for starting new Drupal projects.
A package to cast json fields, each sub-keys is castable
统计信息
- 总下载量: 4
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 11
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: GPL-2.0
- 更新时间: 2019-06-14