kmarenov/yii2-instagram-widget

此包已弃用且不再维护。未建议替代包。

允许您在网站上展示您的Instagram照片

安装次数: 24,926

依赖者: 0

建议者: 0

安全性: 0

星标: 9

关注者: 3

分支: 3

公开问题: 1

类型:yii2-extension

1.0.1 2015-12-07 21:13 UTC

This package is not auto-updated.

Last update: 2023-01-07 09:12:07 UTC


README

Yii2 Instagram Widget 允许您在基于Yii Framework 2的网站上展示您的Instagram照片。

此小部件基于 aik27 的 inwidget,并使用 cosenary 的 Instagram API的PHP包装器

Example

Widget 支持俄语和英语翻译(取决于应用程序的语言配置)

安装

安装此扩展的首选方式是通过 composer

运行以下命令之一:

php composer.phar require --prefer-dist kmarenov/yii2-instagram-widget "*"

或者添加以下内容到您的 composer.json 文件的 require 部分:

"kmarenov/yii2-instagram-widget": "*"

到您的 composer.json 文件的 require 部分。

使用

安装扩展后,只需在代码中简单使用即可

<?= \kmarenov\instagram\InstagramWidget::widget([
        'clientId' => '<your-instagram-client-id>',
        'userName' => 'shnurovs'
    ]);
?>

您必须将您的Instagram Client Id放入 'clientId' 选项中。

如何获取Instagram Client Id

  1. 访问 Instagram开发者网站
  2. 注册您的应用程序
  3. 您现在可以看到一个Client ID

Yii2 Instagram Widget 可以通过Instagram用户名或标签来显示照片。

如果您想通过标签获取照片,请使用以下代码

<?= \kmarenov\instagram\InstagramWidget::widget([
        'clientId' => '<your-instagram-client-id>',
        'tag' => 'cat'
    ]);
?>

Widget选项

  • clientId : 您的Instagram Client Id
  • userName : 您想展示照片的用户的Instagram用户名
  • tag : 如果您想通过标签展示照片,请使用标签
  • showBy : (usertag) 如果设置了 userNametag 选项,您可以选择如何显示照片:通过用户名或通过标签
  • isCacheEnabled : (truefalse) 启用缓存(默认:true)
  • cacheTime : 缓存生命周期(默认:3600 = 1小时)
  • width : Widget 宽度(默认:260像素)
  • imgWidth : 一张图片的宽度(默认:0 = 自动计算)
  • inline : 一行中图片的数量(默认:4)
  • isShowToolbar : (truefalse) 显示或隐藏工具栏(默认:true)
  • count : 显示的图片总数(默认:12)
  • imgRes : (low_resolution - 320x320, thumbnail - 150x150, standard_resolution - 640x640) 图片分辨率(默认:thumbnail)

警告:由于Instagram API每天请求次数有限,因此启用缓存是强烈建议的!

示例

默认

<?= \kmarenov\instagram\InstagramWidget::widget([
        'clientId' => '<your-instagram-client-id>',
        'userName' => 'shnurovs'
    ]);
?>

Example

无工具栏

<?= \kmarenov\instagram\InstagramWidget::widget([
        'clientId'      => '<your-instagram-client-id>',
        'userName'      => 'shnurovs',
        'isShowToolbar' => false
    ]);
?>

Without toolbar

迷你

<?= \kmarenov\instagram\InstagramWidget::widget([
        'clientId'      => '<your-instagram-client-id>',
        'userName'      => 'shnurovs',
        'isShowToolbar' => false,
        'width'         => 100,
        'inline'        => 2
    ]);
?>

Mini

<?= \kmarenov\instagram\InstagramWidget::widget([
        'clientId'      => '<your-instagram-client-id>',
        'userName'      => 'shnurovs',
        'isShowToolbar' => false,
        'width'         => 100,
        'inline'        => 1,
        'count'         => 3
    ]);
?>

Mini

水平

<?= \kmarenov\instagram\InstagramWidget::widget([
        'clientId'      => '<your-instagram-client-id>',
        'userName'      => 'shnurovs',
        'isShowToolbar' => false,
        'width'         => 800,
        'inline'        => 7,
        'count'         => 14
    ]);
?>

Horisontal

大预览

<?= \kmarenov\instagram\InstagramWidget::widget([
        'clientId'      => '<your-instagram-client-id>',
        'userName'      => 'shnurovs',
        'isShowToolbar' => false,
        'width'         => 800,
        'inline'        => 3,
        'count'         => 9,
        'imgRes'        => 'low_resolution'
    ]);
?>

Big previews