PHP code example of vikadata / vika
1. Go to this page and download the library: Download vikadata/vika library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
vikadata / vika example snippets
ika\Vika;
echo '<pre>';
Vika::auth('your api token');
//$datasheet = Vika::datasheet('dst0Yj5aNeoHldqvf6');
$all = Vika::datasheet('your dstId')->all([
"fieldKey" => 'id'
]);
var_dump(json_encode($all->getData()->getRecords()));
$page = Vika::datasheet('dst0Yj5aNeoHldqvf6')->get(['pageNum' => 2, 'pageSize' => 2]);
var_dump(json_encode($page->getData()->getRecords()));
$attach = Vika::datasheet('dst0Yj5aNeoHldqvf6')->upload(__DIR__.'/image.png');
var_dump($attach);
$insertArr = [
[
'fields' => ['数字ID' => 88],
],
[
'fields' => ['数字ID' => 99],
]
];
$insert = Vika::datasheet('dst0Yj5aNeoHldqvf6')->add($insertArr, 'name');
var_dump('insert message ' . $insert->getMessage());
$insertRecords = $insert->getData()->getRecords();
$updateArr = [
[
'recordId' => $insertRecords[0]['recordId'],
'fields' => ['数字ID' => 100],
],
[
'recordId' => $insertRecords[1]['recordId'],
'fields' => ['数字ID' => 101],
]
];
$update = Vika::datasheet('dst0Yj5aNeoHldqvf6')->update($updateArr, 'name');
var_dump('update message ' . $update->getMessage());
$delete = Vika::datasheet('dst0Yj5aNeoHldqvf6')->del([$insertRecords[0]['recordId'], $insertRecords[1]['recordId'],]);
var_dump('delete message ' . $delete->getMessage());
echo '</pre>';