1
0
mirror of https://github.com/Bayselonarrend/OpenIntegrations.git synced 2024-12-18 23:48:56 +02:00
OpenIntegrations/docs/en/md/VK/Community-managment/Create-composite-post.md

72 lines
2.0 KiB
Markdown
Raw Normal View History

---
sidebar_position: 2
---
# Create composite post
Creates a post based on an array of object identifiers (images, videos, etc..)
<br/>
2024-07-10 12:58:29 +02:00
`Function CreateCompositePost(Val Text, Val Objects, Val Advertisement = False, Val LinkUnderPost = "", Val Parameters = "") Export`
| Parameter | CLI option | Type | Destination |
|-|-|-|-|
| Text | --text | String | Post text |
| Objects | --objects | Array of String | Array of identifiers like photo123_123 |
| Advertisement | --ad | Boolean | Sign ""This is an ad"" |
| LinkUnderPost | --url | String | Link (URL) under the post |
| Parameters | --auth | Structure Of String | Authorization JSON or path to .json |
Returns: Map Of KeyAndValue - Serialized JSON response from VK
2024-07-10 13:05:58 +02:00
<br/>
2024-07-10 12:58:29 +02:00
```bsl title="Code example"
2024-07-10 13:24:11 +02:00
Parameters = GetVKParameters();
Text = "Post from autotest";
URL = "https://github.com/Bayselonarrend/OpenIntegrations";
Image = "https://openintegrations.dev/test_data/picture.jpg"; // URL, Path or Binary Data
Video = "https://openintegrations.dev/test_data/video.mp4"; // URL, Path or Binary Data
TFN = GetTempFileName("png");
FileCopy(Image, TFN);
ImageUpload = OPI_VK.UploadPhotoToServer(TFN, Parameters)["response"][0];
VideoUpload = OPI_VK.UploadVideoToServer(Video, "NewVideo",,, Parameters);
ImageOwner = OPI_Tools.NumberToString(ImageUpload["owner_id"]);
VideoOwner = OPI_Tools.NumberToString(VideoUpload["owner_id"]);
ImageID = OPI_Tools.NumberToString(ImageUpload["id"]);
VideoID = OPI_Tools.NumberToString(VideoUpload["video_id"]);
AttachmentsArray = New Array;
AttachmentsArray.Add("photo" + ImageOwner + "_" + ImageID);
AttachmentsArray.Add("video" + VideoOwner + "_" + VideoID);
Result = OPI_VK.CreateCompositePost(Text, AttachmentsArray, False, URL, Parameters);
```
```sh title="CLI command example"
oint vk CreateCompositePost --text %text% --objects %objects% --ad %ad% --url %url% --auth %auth%
```
```json title="Result"
2024-07-10 13:11:17 +02:00
{
"response": {
"post_id": 2126
}
}
```