lezhnev/instagram2vk

Instagram2VK.com Reposter 是一个库,用于将 Instagram 图片发布到 VK.com 社区墙

0.0.4 2016-01-07 15:30 UTC

This package is auto-updated.

Last update: 2024-08-29 04:14:28 UTC


README

License Latest Stable Version

Instagram 到 vk.com 的重发器正好做这个 - 安排 Instagram 照片的 VK.com 墙(社区墙)重发

  • 你可以设置 Instagram 用户名和标签来收集照片;
  • 你可以设置确切的发布时间和星期几以安排 VK.com 的发布。

需求

为了运行此脚本,你需要

  • Instagram access_token(确保 access_token 不是用于沙盒模式的 app)。Access token 必须具有作用域:basicpublic_content
  • Vk.com access_token 用于重发照片(必须具有在指定墙上发布的权利)。

安装

只需运行 composer

composer require lezhnev/instagram2vk

示例

use GuzzleHttp\Client;
use Instagram2Vk\Classes\State;
use Instagram2Vk\Classes\VkPoster;
use Instagram2Vk\Classes\InstagramCrawler;
use Instagram2Vk\Classes\VkPostTimeScheduler;
use Instagram2Vk\Classes\VkPostTransformer;


$client = new Client(); // guzzle client for HTTP requests
$state = new State("file.sqlite"); // sqlite database for state storage
$transformer = new VkPostTransformer(); // transformer for instagram posts
$scheduler = new VkPostTimeScheduler(); // scheduler for reposting to VK.com
// set schedule table (Weekday => timeslots)
$scheduler->setScheduleTimeSlots(
    [
        "Mon" => ["12:30", "12:40"],
        "Tue" => [],
        "Wed" => [],
        "Thu" => ["21:30"],
        "Fri" => [],
        "Sat" => [],
        "Sun" => [],
    ]
);


// Crawl new data
$dataSource = new InstagramCrawler($client, "ISNTAGRAM_ACCESS_TOKEN", ["tag1", "moscow", "russia"],["username1", "applemusic"]);
$dataSource->crawl(); // start gathering new posts

// Pass data to VK poster
$poster = new VkPoster(
    $scheduler,
    $transformer,
    $dataSource,
    $client,
    $state,
    "VK_ACCESS_TOKEN",
    "VK_COMMUNITY_ID"
);

$poster->run(); // schedule new posts to VK

支持

请随时添加 PR 或给我发送邮件至 meekman74@gmail.com