MODX Community

Gallery API - Adding pictures to Album

Hi!
I need to create Gallery albums and fill albums with images using API.
I can create an album with modx processors, but filling it with images does not work. Images are already uploaded to the site.
I use this code:

        <?php
    define('MODX_API_MODE', true);
	require $_SERVER['DOCUMENT_ROOT'].'/index.php';

	$modx->getService('error','error.modError');
	$modx->setLogLevel(modX::LOG_LEVEL_INFO);
	$modx->setLogTarget(XPDO_CLI_MODE ? 'ECHO' : 'HTML');
	
	$nameAlbum = 'galAlbum';
    	$descrAlbum = 'Thats demo album';
	
	$responseGallery = $modx->runProcessor('mgr/album/create',
        array(
            'name' => $nameAlbum,
            'description' => $descrAlbum,
            'active' => 1,
            'prominent' => 1,
        ),
        array(
            'processors_path' => $modx->getOption('core_path') . 'components/gallery/processors/',
        )
    );

    $galleryID = $responseGallery->response['object']['id'];


    $res = $modx->newObject('modResource');
    $res->save();
    $res->setTVValue('photos', $galleryID);
    
            $responseGalleryItems = $modx->runProcessor('mgr/item/upload',
                array(
                'album' => $galleryID,
                'active' => 1,
                'name' => 'assets/images/demo.jpg',
                                    ),
                array(
                'processors_path' => $modx->getOption('core_path') . 'components/gallery/processors/',
                                    )
            );