- $req->req->addPostParameter('h', 'entry');
- $req->req->addPostParameter('content', $command->args['text']);
- if ($command->options['published'] !== null) {
- $req->req->addPostParameter(
- 'published', $command->options['published']
- );
- }
-
- $files = $command->options['files'];
- $fileList = [
- 'audio' => [],
- 'photo' => [],
- 'video' => [],
- ];
- $urls = [];
- foreach ($files as $filePath) {
- if (file_exists($filePath)) {
- $type = 'photo';
- $fileList[$type][] = $filePath;
- } else if (strpos($filePath, '://') !== false) {
- //url
- $urls[] = $filePath;
- } else {
- Log::err('File does not exist: ' . $filePath);
- exit(20);
- }
- }
- if (count($urls)) {
- if (count($urls) == 1) {
- $req->req->addPostParameter('photo', reset($urls));
- } else {
- $n = 0;
- foreach ($urls as $url) {
- $req->req->addPostParameter(
- 'photo[' . $n++ . ']', reset($urls)
- );
- }
- }
- }
- foreach ($fileList as $type => $filePaths) {
- if (count($filePaths) == 1) {
- $req->addUpload($type, reset($filePaths));
- } else if (count($filePaths) > 0) {
- $req->addUpload($type, $filePaths);
- }
- }
+ $req->setType('entry');
+ $req->addContent($cmdRes->args['text'], $cmdRes->options['html']);
+ $this->handleGenericOptions($cmdRes, $req);