kerigansolutions/instagram-autogallery-wp

1.2 2023-03-23 13:46 UTC

This package is auto-updated.

Last update: 2024-09-23 17:08:58 UTC


README

轻松将帖子从您管理的与Facebook商业页面链接的Instagram页面拉入WordPress站点。需要WordPress,并在WordPress中创建一个特殊的Admin页面。帖子通过每小时运行一次的cron任务从Instagram获取并添加到WP数据库中。

状态

目前该应用程序配置为与帖子一起使用。

安装

composer require kerigansolutions/fb-instagram-wp

设置

  1. 确保您有FB页面的管理员权限,并且它已链接到您需要同步的Instagram页面。
  2. 登录WordPress并转到新的Instagram设置菜单项。
  3. 使用应用密钥授权应用程序(提示:只有KMA知道这个)。
  4. 使用授权工具授权应用程序使用您管理的Facebook页面,并选择Instagram动态。
  5. 使用同步工具构建帖子数据库。
  6. 在模板中编写视图以显示数据。

包含或扩展WP Admin类

use KeriganSolutions\Instagram;
use KeriganSolutions\Instagram\WP\InstagramPost;

class Instagram extends Instagram\WP\Admin
{

  // retrieve posts from WP database
  public function getInstagramPosts($num = -1, $args = [])
  {
    return (new InstagramPost())->query($num, $args);
  }
  
}

或直接进行API调用并检索结果

use KeriganSolutions\Instagram\WP\InstagramPost;

$feed  = new InstagramPost;
$results = $feed->query(5);
fetch("/wp-json/kerigansolutions/v1/get-kma-instagram-post", {
    method: 'GET',
    mode: 'cors',
    cache: 'no-cache',
    headers: {
        'Content-Type': 'application/json',
    },
})
.then(r => r.json())
.then((res) => {
    // do something with res
})