jacob-ian/instagram-feed 问题修复 & 功能扩展

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

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

jacob-ian/instagram-feed

Composer 安装命令:

composer require jacob-ian/instagram-feed

包简介

A simple Instagram feed using the old Instagram API

README 文档

README

An Instagram Feed using the old API. It will cache the post data in your webserver and use a MYSQL database to store the metadata to maximise loading speeds.

Requirements:

  • An Instagram Access Token connected to the desired account to display. Note: The account must be public.
  • PHP 7.2+

Usage:

  1. Include this repository in your project via Composer (jacob-ian/instagram-feed).

  2. Create a MYSQL Database to hold the data:

    CREATE DATABASE instagram

    The \JacobIan\InstagramFeed\instagramFetch class will automatically create the table and populate it.

  3. Setup a cron-job that will point to a PHP file containing:

    require_once('instagram-feed/src/instagramFetch.class.php');
    $instagramData = new \JacobIan\InstagramFeed\instagramFetch($database, $accesstoken, $cachepath);
    $instagramData->fetch();

    The require_once() can be replaced with an autoloader.

    Where:

    • $database should be an array with the structure:

       $database = array(
       	"username"=>"[username]",
       	"password"=>"[password]",
       	"host"=>"[host]",
       	"database"=>"instagram"
       );
    • $accesstoken is a string containing the Instagram Access Token relating to the account you wish to display.

    • $cachepath should be a string with the path to a location in the public_html/webroot directory where you wish the Instagram Cache and Assets to be stored.

    This cron job should run every 15 minutes, but frequency can be increased depending on how often you wish the feed to refresh.

  4. To create the feed itself, use the following code on your PHP webpage:

    require_once('instagram-feed/src/instagramFeed.class.php');
    $instagram_feed = new \JacobIan\InstagramFeed\instagramFeed($database, $count, $style);
    echo $instagram_feed->feed();

    Again, the require_once() can be replaced by an autoloader.

    Where:

    • $count is an integer describing the number of latest posts to display in the feed. Instagram API is limited to a maximum of 20 posts.
    • $style is a string containing the desired CSS Style tags on each Instagram Post. See CSS Styles below.
  5. Include the following two lines of code to the <head> of the webpage containing the Instagram Feed:

    <link rel="stylesheet" type="text/css" href="https://min.gitcdn.xyz/repo/jacob-ian/instagram-feed/master/css/feed.css"/>
    <script src="https://min.gitcdn.xyz/repo/jacob-ian/instagram-feed/master/js/feed.js"></script>
  6. Enjoy!

CSS Styles:

The available CSS tags are:

Size:

  • 'small' : Grid size of 150x150px with a frame around the media

  • 'medium' : Grid size of 300x300px with a frame around the media

  • 'large' : Grid size of 640x640px with a frame around the media

  • 'small_noframe' : Grid size of 150x150px without a frame

  • 'medium_noframe' : Grid size of 300x300px without a frame

  • 'large_noframe' : Grid size of 640x640px without a frame

Color:

  • 'dark' : Sets post background-color to #333 (dark-grey)
  • 'transparent' : Sets post background-color to transparent
  • 'noborder' : Removes the border on the posts
  • Note: the default background-color is #fff (white).

Spacing:

  • 'nomargin' : Removes the gap between the posts in the Instagram Feed grid.

Example Styles:

  • 'small dark' : A small grid size with a frame of colour #333 around the media
  • 'large_noframe nomargin noborder' : A large grid size without a frame and no gaps between the posts. This setup makes it easy to use the Masonry JS Script.

Usage:

  • Only one Size tag can be used, and it is also the minimum requirement for the feed to work.
  • After the size tag, the other tags can be added on with a space in between.

Custom Styles:

  • Custom Styles can be used by adding them to the $style string with a space.
  • To use a custom size style, the size tag can be replaced by a custom string. This will then be converted to the CSS tag post_[custom] and media_[custom].

Notes:

  • The \JacobIan\InstagramFeed\instagramFetch class automatically transfers the contents of '..\assets' to the cache folder that is publicly accessable.
  • \JacobIan\InstagramFeed\instagramFetch creates a database table named 'details' which contains the following information:
    • UserID: Instagram User ID
    • ProfilePictureURL: The URL to your profile picture
    • ProfilePicturePath: The path to the locally stored copy of your profile picture
    • Followers: Your follower count
    • Posts: Your post count
    • LastUpdate: The time of the last successful instagramFetch cron job.
    • CachePath: The path where your Instagram Cache and Assets are stored.

jacob-ian/instagram-feed 适用场景与选型建议

jacob-ian/instagram-feed 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 7 次下载、GitHub Stars 达 1, 最近一次更新时间为 2018 年 06 月 27 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 jacob-ian/instagram-feed 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2018-06-27