blackmagic/instagrammedia
Composer 安装命令:
composer require blackmagic/instagrammedia
包简介
Plugin to retrieve instagram media using Facebook's Instagram Basic API
README 文档
README
Craft 3 CMS Plugin to retrieve Instagram media (from an account you have access to) using Facebook’s “Instagram Basic API”
I created this plugin to streamline and facilitate a way to retrieve data from an Instagram account that I have access to. As of now this plugin, will not auto-renew long live token. In order to renew it you have to re-save the plugin before the token expires.
Requirements:
- Craft 3
- espresso-dev/instagram-basic-display-php
Installation
cd /path/to/project
composer require heyblackmagic/instagrammedia
./craft install/plugin instagrammedia
Configuration
In order to work with Facebook's Instagram Basic API you need to have previously created an application with a Facebook Developer account. Please follow intructions here if you are not sure how to achieve this.
After the application is set up, you should have a Instagram App Id, Instagram App Secret and Instagram App Redirect URI.
-
In Craft CMS, switch to the Settings page in the control panel and enter the values mentioned above and click Save. If all the fields are entered correcltly, after saving, you should now see a Get Auth Link red button and an empty field for Instagram's API Token.
-
Click "Get Auth Link", this will redirect you to a 404 page (this is intended) inside your site. The URL should look something like this:
https://mywebsite.com/auth/?code=AQBx-hBsH3...#_ -
Copy the code between (exclusive) the
=and#_Note that#_will be appended to the end of the redirect URI, but it is not part of the code itself, so strip it out. Paste this code in the Instgram API Token field in the plugin's settings and click Save.
If everything was set up correctly you should now see a Conection succesfull to Instgram's API message and an expiration day equal to 60 days. In order to renew the token before it expires you just have to save the plugin and it will renew the long-live token.
Usage
To fetch the media from your account call getMedia()
you can check all available fields on Instagram Basic API Docs
Eg:
{% set media = craft.instagram.getMedia() %}
{% for item in media %}
<li>
...
</li>
{% endfor %}
Here is an example if you need to check if the item has a caption or if the item is a video or an image. You need to make this check because images and videos have different sources for image url and video thumbnail respectively:
{% set media = craft.instagram.getMedia() %}
{% for item in media %}
{% set permalink = item.permalink %}
{% set caption = item.caption is defined ? item.caption : 'Instgram Picture' %}
<li>
{% if item.media_type == 'VIDEO'%}
<a href="{{permalink}}" target="_blank"><img src="{{item.thumbnail_url}}" alt="{{caption}}"></a>
{% else %}
<a href="{{permalink}}" target="_blank"><img src="{{item.media_url}}" alt="{{caption}}"></a>
{% endif %}
</li>
{% endfor %}
To Do:
- Add auto renew of long live token.
- Better error handling.
- Add limit on how many posts to retrieve.
blackmagic/instagrammedia 适用场景与选型建议
blackmagic/instagrammedia 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 967 次下载、GitHub Stars 达 3, 最近一次更新时间为 2020 年 03 月 06 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「cms」 「Craft」 「craftcms」 「craft-plugin」 「instagrammedia」 「instgram」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 blackmagic/instagrammedia 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 blackmagic/instagrammedia 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 blackmagic/instagrammedia 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Expand, collapse, change the status of, or delete multiple blocks in a Matrix field simultaneously.
GraphQL authentication for your headless Craft CMS applications.
Set Links with a specific language parameter
Supercharged text field validation.
Integrate with Snipcart.
Restrict user registration by domain in Craft CMS, allows you to limit who can register for your site based on their email address.
统计信息
- 总下载量: 967
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 6
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-03-06