Ejemplo n.º 1
0
        //        ]);
        $data = ['photo' => $photo, 'server' => $server, 'hash' => $hash, 'group_id' => $this->groupId * -1];
        $result = $this->callApi('photos.saveWallPhoto', $data, 'post');
        return $result;
    }
    public function post($publishDate, $photos)
    {
        $data = ['owner_id' => $this->groupId, 'message' => $this->post['text'], 'attachments' => implode(',', $photos), 'publish_date' => $publishDate];
        $result = $this->callApi('wall.post', $data, 'post');
        return $result;
    }
    public function getPhotosByResponse($response)
    {
        $photos = [];
        foreach ($response['response'] as $key => $photo) {
            $photos[] = $photo['id'];
        }
        return $photos;
    }
}
if (isset($_REQUEST['group_id']) && isset($_REQUEST['publish_date'])) {
    $vk = new VkApi($_COOKIE['vk-token'], $_REQUEST['group_id'], $_COOKIE['vk-user-id']);
    $vk->setPost($_REQUEST['post']);
    $result = $vk->curlPost();
    //    PR($result);
    //    die();
    //$photosResponse = $vk->saveWallPhoto($result['photo'], $result['server'], $result['hash']);
    $resPost = $vk->post($_REQUEST['publish_date'], $vk->getPhotosByResponse($result));
    echo json_encode($resPost);
    die;
}