lerni/instagram-basic-display-feed-element 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

lerni/instagram-basic-display-feed-element

Composer 安装命令:

composer require lerni/instagram-basic-display-feed-element

包简介

Instagram Feed for Silverstripe Elemental features Basic Display PHP API (instagram_business_basic scope)

README 文档

README

Instagram feed in a dnadesign/silverstripe-elemental-element. It utilizes espresso-dev/instagram-php and caches the API-response for performance reasons. Since different scrapers lead to all sorts of problems - mostly cookie/session related, this module came to existence. appId & appSecret are stored in yml-config or .env, the rotating token in DB.

License

Instagram feed module screenshot Example in action from Lipp&Leuthold

Installation

Composer is the recommended way installing Silverstripe modules.

composer require lerni/instagram-basic-display-feed-element
  • Run a dev/build

Requirements

  • Silverstripe 6.x
  • dnadesign/silverstripe-elemental
  • espresso-dev/instagram-php 1.x

Configuration

You'll need to set up a FB App and set appId & appSecret (Instagram not FB). redirectUri will be DYNAMICALLY-SET-HOST.TLD/_instaauth but you can also set it explicitly with a domain per yml-config. Make sure to configure the correct values (e.g. dev-url) in your FB App! If no token is generated yet, you'll find a link to generate one in the settings tab of the element. The token 'll be renewed automatically (on request basis) if older than 30 days.

  1. Install the module
  2. Create a FB App use https://DOMAIN.TLD/_instaauth as redirectUri
    • create an Instagram app on https://developers.facebook.com/apps/?locale=en_US
      • click on "Create App"
        • Filter all
        • choose "Manage messaging & content on Instagram"
      • On Dashboard personalize "Messaging und Content"
        • Copy "Instagram app ID" add it to KRAFT_INSTAFEED_APP_ID in .env
        • Copy "Instagram app secret" add it to KRAFT_INSTAFEED_APP_SECRET in .env
        • Make sure "instagram_business_basic" is set
        • Set "Callback URL" to https://DOMAIN.TLD/_instaauth
        • Set "Verify token" to the same as KRAFT_INSTAFEED_VERIFICATION_TOKEN in .env (something random)
        • "Set up Instagram business login" you can use https://DOMAIN.TLD/_instaauth again Sometimes you just can't - try reloading, different browser or do some other black magic 🤷
    • add Instagram-Tester (Roles → Add → Instagram-Tester)
    • Login on Instagram & accept/confirm
      • Settings
        • Website Permissions
          • Apps and Websites
            • Accept Tester Invitations
  3. Add appId, appSecret & verificationToken in yml-config or .env like below & ?flush
    • make sure to use the credentials from the Instagram settings, not the general App Settings!
  4. Create an Instagram Feed Element & click on the link in the settings tab to authenticate
  5. Reload CMS to see the generated token
  6. That's it. The token will be updated if older than 30 days on request basis. This means, if a token is older than 30 days and from then on no request is made (element never shown to any visitor), the token invalidates and a warning is thrown. To fix this, delete all tokens and regenerate one with the link provided in CMS.
Kraftausdruck\InstagramFeed\Control\InstaAuthController:
  credentials:
    appId: '2598599940246020'
    appSecret: '7e29795bva6d352e3286769ff3a3a836'
    verificationToken: 'SetThisToSomethingRandom'
    # redirectUri: 'https://example.tld/_instaauth'
KRAFT_INSTAFEED_APP_ID='2598599940246020'
KRAFT_INSTAFEED_APP_SECRET='7e29795bva6d352e3286769ff3a3a836'
KRAFT_INSTAFEED_VERIFICATION_TOKEN='SetThisToSomethingRandom'

Styling

Example styling with text as hover overlay.

CSS with a bit PostCSS magic
.instafeed {
	display: flex;
	flex-wrap: wrap;
	margin-left: -1px;
	margin-right: -1px;
	width: calc(100% + 2px);
	a {
		outline: none;
		overflow: hidden;
		position: relative;
		display: block;
		width: auto;
		height: 500px;
		@media (max-width: 980px) {
			height: 400px;
		}
		@media (max-width: 480px) {
			height: 300px;
		}
		figure {
			height: 100%;
			margin: 0;
			img {
				object-fit: cover;
				margin-bottom: 0;
				max-width: none;
				width: 100%;
				height: 100%;
			}
			figcaption {
				position: absolute;
				inset: 0;
				opacity: 0;
				transition: opacity 120ms linear;
				z-index: 1;
				color: var(--white);
				font-size: var(--font-size--small);
				padding: calc(var(--lh) * 1em);
				display: flex;
				flex-direction: column;
				background-color: rgba(0,0,0,.8);
				overflow-wrap: break-word;
				word-wrap: break-word;
				span[data-icon="instagram"] {
					transition: transform 120ms linear;
					transform: scale(.4);
					width: 1lh;
					height: 1lh;
					background-image: svg-load("instagram.svg", stroke=#fff);
					margin: auto auto 0 auto;
				}
			}
            @media (hover: hover) {
                &:hover {
                    figcaption {
                        opacity: 1;
                        span[data-icon="instagram"] {
                            transform: scale(1);
                        }
                    }
                }
            }
		}
		video {
			height: 100%;
			width: 100%;
		}
        @media (hover: none) {
            &:focus,
            &:focus-within,
            &:active {
                figure figcaption {
                    pointer-events: none;
                    opacity: 1;
                    span[data-icon="instagram"] {
                        transform: scale(1);
                    }
                }
            }
        }
	}
}

Troubleshooting

If things go wrong, you may want to check Facebook Platform Status.

lerni/instagram-basic-display-feed-element 适用场景与选型建议

lerni/instagram-basic-display-feed-element 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 869 次下载、GitHub Stars 达 3, 最近一次更新时间为 2020 年 02 月 27 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「instagram」 「silverstripe」 「elemental」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

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

围绕 lerni/instagram-basic-display-feed-element 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 869
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 16
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2020-02-27