ApiHelper
Class ApiHelper - formatted and run requests to VK Api. Provide utility functions for help.
Table of Contents
Methods
- __construct() : mixed
- ApiHelper constructor.
- addResultToData() : array<string|int, mixed>
- Merge to arrays by reference key
- changeArrayMainKey() : array<string|int, mixed>
- Reformat array - change main (top level) key.
- extractItemsFromArray() : array<string|int, mixed>
- Extract specified elements from array. Need to decrease of array size to post
- getALbumsFromVk() : array<string|int, mixed>
- Get list of VK albums from VK API
- getProductsFromVk() : array<string|int, mixed>
- Get list of VK products from VK API
- getUserGroupsSelector() : mixed
- getVkCategories() : array<string|int, mixed>
- Get list of VK product categories from VK API
- prepareProductsDataToVk() : array<string|int, mixed>
- Check params for save products data.
- uploadPhotos() : array<string|int, mixed>
- Check photo size, get upload server, upload photo and save them
Methods
__construct()
ApiHelper constructor.
public
__construct(mixed $exportId) : mixed
Parameters
- $exportId : mixed
-
- int, ID of export profile
addResultToData()
Merge to arrays by reference key
public
static addResultToData([array<string|int, mixed> $data = array() ][, array<string|int, mixed> $result = array() ], mixed $referenceKey) : array<string|int, mixed>
Parameters
- $data : array<string|int, mixed> = array()
- $result : array<string|int, mixed> = array()
- $referenceKey : mixed
-
- main key in both arrays
Return values
array<string|int, mixed>changeArrayMainKey()
Reformat array - change main (top level) key.
public
static changeArrayMainKey([array<string|int, mixed> $data = array() ], mixed $mainKey[, string $keyRename = '' ]) : array<string|int, mixed>
Parameters
- $data : array<string|int, mixed> = array()
- $mainKey : mixed
- $keyRename : string = ''
-
- if isset, new main key will be rename
Return values
array<string|int, mixed>extractItemsFromArray()
Extract specified elements from array. Need to decrease of array size to post
public
static extractItemsFromArray([array<string|int, mixed> $data = array() ][, array<string|int, mixed> $keys = array() ]) : array<string|int, mixed>
Parameters
- $data : array<string|int, mixed> = array()
-
- source array
- $keys : array<string|int, mixed> = array()
-
- array of keys, thst needed in new array
Return values
array<string|int, mixed> —- array of extracted items
getALbumsFromVk()
Get list of VK albums from VK API
public
getALbumsFromVk(mixed $vkGroupId[, bool $flip = true ]) : array<string|int, mixed>
Parameters
- $vkGroupId : mixed
- $flip : bool = true
Return values
array<string|int, mixed> —- list of VK albums
getProductsFromVk()
Get list of VK products from VK API
public
getProductsFromVk(mixed $vkGroupId) : array<string|int, mixed>
Parameters
- $vkGroupId : mixed
Return values
array<string|int, mixed> —- list of VK products
getUserGroupsSelector()
public
getUserGroupsSelector([mixed $selectedValue = null ][, mixed $name = null ][, mixed $id = null ]) : mixed
Parameters
- $selectedValue : mixed = null
- $name : mixed = null
- $id : mixed = null
getVkCategories()
Get list of VK product categories from VK API
public
getVkCategories([int $count = Vk::MAX_VK_CATEGORIES ][, int $offset = 0 ]) : array<string|int, mixed>
Parameters
- $count : int = Vk::MAX_VK_CATEGORIES
- $offset : int = 0
Return values
array<string|int, mixed> —- Get list of VK product categories. Return false if error
prepareProductsDataToVk()
Check params for save products data.
public
static prepareProductsDataToVk(mixed $data) : array<string|int, mixed>
Check photos, description, vk-category
Parameters
- $data : mixed
Return values
array<string|int, mixed> —- prepared to save data array
uploadPhotos()
Check photo size, get upload server, upload photo and save them
public
uploadPhotos(mixed $data, mixed $vkGroupId, mixed $uploadType[, null $timer = NULL ]) : array<string|int, mixed>
use PhotoUploader class
Parameters
- $data : mixed
- $vkGroupId : mixed
- $uploadType : mixed
-
- type of photo. For other types used other params and methods
- $timer : null = NULL
-
- timer for control time of upload
Tags
Return values
array<string|int, mixed> —- array of save photos results