定制 subb98/vk-publisher 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

subb98/vk-publisher

Composer 安装命令:

composer require subb98/vk-publisher

包简介

Auto-sending (crossposting) messages to VKontakte wall

README 文档

README

PHP library for auto-sending (crossposting) messages to VKontakte wall

Build Status StyleCI Latest Stable Version Total Downloads Latest Unstable Version License

Features

  • Send a message or attachment (or all together) to the wall
  • Upload photo (external or local) to album

Requirements

Installation

composer require subb98/vk-publisher

Usage

Getting access_token

For one step

  1. Getting access_token
    • Request example: https://oauth.vk.com/authorize?client_id=1234567&display=page&redirect_uri=&scope=photos,wall,groups,offline&response_type=token&v=5.103
    • Response example: https://oauth.vk.com/blank.html#access_token=fe8c3650bdf7ad7185598c5a32c43a4e8d38bf1135e7d7920fdafd5dc5615949ba3fc7b461d6fd120b97f&expires_in=0&user_id=89012345

Or for two steps

  1. Getting the code to get access_token

    • Request example: https://oauth.vk.com/authorize?client_id=1234567&display=page&redirect_uri=&scope=photos,wall,groups,offline&response_type=code&v=5.103
    • Response example: https://oauth.vk.com/blank.html#code=3b2a554d20bd48c360
  2. Getting access_token

    • Request example: https://oauth.vk.com/access_token?client_id=1234567&client_secret=9Wnk7UcEpeFAHhJYyyJg&redirect_uri=&code=3b2a554d20bd48c360
    • Response example: {"access_token":"fe8c3650bdf7ad7185598c5a32c43a4e8d38bf1135e7d7920fdafd5dc5615949ba3fc7b461d6fd120b97f","expires_in":0,"user_id":89012345}

Note: don't use scope=offline if you fear access_token is may be compromised.
See more: Getting access token

Sending a message to the wall

Without photo

use Subb98\VkPublisher\Models\Settings;
use Subb98\VkPublisher\Services\PostSenderService;

$settings = (new Settings())
    ->setOwnerId(-169116756) // you need a minus sign if it's a group
    ->setAccessToken('fe8c3650bdf7ad7185598c5a32c43a4e8d38bf1135e7d7920fdafd5dc5615949ba3fc7b461d6fd120b97f')
    ->setApiVersion('5.103');

$postSender = new PostSenderService($settings);
$postSender->sendPostToWall("Message sends by \"VK Publisher\" PHP library\n\nLorem ipsum, dolor sit amet consectetur adipisicing elit. Tenetur unde libero quidem adipisci fugiat, error facilis ducimus, veritatis id amet nemo. Mollitia corporis vel quae rerum deleniti! Ducimus, corporis optio.");

With photo(s)

use Subb98\VkPublisher\Services\PhotoUploaderService;

$settings->setAlbumId(256572563);

$photoUploader = new PhotoUploaderService($settings);

$photos[] = $photoUploader->uploadPhotoToAlbum('https://i.imgur.com/G82OZCz.jpg');
$photos[] = $photoUploader->uploadPhotoToAlbum(__DIR__ . '/img/peter-as-superman.jpg');
$postSender->sendPostToWall("Message sends by \"VK Publisher\" PHP library\n\nLorem ipsum, dolor sit amet consectetur adipisicing elit. Tenetur unde libero quidem adipisci fugiat, error facilis ducimus, veritatis id amet nemo. Mollitia corporis vel quae rerum deleniti! Ducimus, corporis optio.", $photos);

License

MIT

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-07-22

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固