tristanward/tinygram 问题修复 & 功能扩展

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

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

tristanward/tinygram

Composer 安装命令:

composer require tristanward/tinygram

包简介

A light-weight Instagram integration. Pull recent Instagram images into a Laravel website.

README 文档

README

A light-weight Instagram integration. Pull recent Instagram images into a Laravel website.

Installation

Install via composer:

$ composer require tristanward/tinygram

Configuration

Tinygram requires an Instagram access token to access recent Instagram posts. Refer to the Instagram docs for help generating an access token.

The Instagram access token should be specified in the Laravel .env file:

INSTAGRAM_ACCESS_TOKEN=

Cache Instagram Posts

Instagram posts can be cached to limit calls to the Instagram API. To do this a tinyimages table must first be created:

php artisan migrate

To cache all recent Instagram posts use the tinygram:cache console command:

php artistan tinygram:cache

This command can be used in Laravel's default scheduler, for example to cache recent Instagram posts at 03:00 on Sundays:

// App/Console/Kernel.php

use Tristanward\Tinygram\Console\TinygramCache;

protected $commands = [
    ...
    TinygramCache::class,
];

protected function schedule(Schedule $schedule)
{
    ...
    $schedule->command('tinygram:cache')
        ->sundays()
        ->at('03:00');
}

Usage

Tinygram uses a Laravel facade:

<?php

use Tristanward\Tinygram\Facades\Tinygram;

// Get 9 most recent Cached Instagram posts
$cached = Tinygram::cachedMedia($count = 9);

// Get 9 most recent Instagram posts live from the Instagram API
$recent = Tinygram::recentMedia($count = 9);

// Get full raw data live from the Instagram API
$raw = Tinygram::recentMediaRaw($count = 9);

Output

The cachedMedia() method returns a Laravel collection of Tinyimage objects. The underlying Instagram post information can be access using the Tinyimage object attributes:

$tinyimage->media_id
$tinyimage->link
$tinyimage->location
$tinyimage->standard_url
$tinyimage->thumb_url
$tinyimage->media_created_at

Both the recentMedia() and recentMediaRaw() methods return a Laravel collection of arrays containing data from Instagram. Use dd() on the output of these methods to see available data.

Thanks

https://www.tristanward.co.uk

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-10-27

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固