39 lines
985 B
PHP
39 lines
985 B
PHP
|
<?php
|
||
|
|
||
|
namespace VK;
|
||
|
|
||
|
/**
|
||
|
* Class Post
|
||
|
* @package VK
|
||
|
*/
|
||
|
class Post extends Base
|
||
|
{
|
||
|
|
||
|
/**
|
||
|
* Post constructor.
|
||
|
* @param $vk_api
|
||
|
*/
|
||
|
public function __construct($vk_api)
|
||
|
{
|
||
|
$this->prop_list = ['friends_only', 'from_group', 'services', 'signed', 'publish_date', 'lat', 'long', 'place_id',
|
||
|
'post_id', 'guid', 'mark_as_ads', 'close_comments'];
|
||
|
parent::__construct($vk_api);
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @param $id
|
||
|
* @param null $publish_date
|
||
|
* @return mixed
|
||
|
* @throws VkApiException
|
||
|
*/
|
||
|
public function send($id, $publish_date = null)
|
||
|
{
|
||
|
if ($publish_date >= time())
|
||
|
$this->props['publish_date'] = $publish_date;
|
||
|
else if ($publish_date == null)
|
||
|
$this->props['publish_date'] = time();
|
||
|
else
|
||
|
throw new VkApiException('Неверно указан $publish_date');
|
||
|
return $this->vk_api->createPost($id, $this->message, $this->props, $this->media);
|
||
|
}
|
||
|
}
|