PHP code example of radweb / monday-api

1. Go to this page and download the library: Download radweb/monday-api 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/ */

    

radweb / monday-api example snippets




n = 'API_TOKEN';
$MondayBoard = new TBlack\MondayAPI\MondayBoard();
$MondayBoard->setToken(new TBlack\MondayAPI\Token($token));



# Get all boards
$all_boards = $MondayBoard->getBoards();

# Get Board id : 10012
$board_id = 10012;
$board = $MondayBoard->on($board_id)->getBoards();

# Get Board Columns
$board_id = 10012;
$boardColumns = $MondayBoard->on($board_id)->getColumns();

# Create Board, if success return board_id
$newboard = $MondayBoard->create( 'New Board Name', TBlack\MondayAPI\ObjectTypes\BoardKind::PUB );
$board_id = $newboard['create_board']['id'];


# Insert new Item on Board
$board_id = 10012;
$id_group = 'topics';
$column_values = [ 'text1' => 'Value...','text2' => 'Other value...' ];

$addResult = $MondayBoard
              ->on($board_id)
              ->group($id_group)
              ->addItem( 'My Item Title', $column_values );

# If you want to use the `create_labels_if_missing` arguments; just add `true` as the third arguments (default: `false`)
$addResult = $MondayBoard
              ->on($board_id)
              ->group($id_group)
              ->addItem( 'My Item Title', $column_values, true);

# if succes return
$item_id = $addResult['create_item']['id'];

# For update Item
$item_id = 34112;
$column_values = [ 'text1' => 'New Value','text2' => 'New other value...' ];

$updateResult = $MondayBoard
              ->on($board_id)
              ->group($id_group)
              ->changeMultipleColumnValues($item_id, $column_values );

# Archive item
$result = $MondayBoard
              ->on($board_id)
              ->group($id_group)
              ->archiveItem($item_id);

// Delete item
$result = $MondayBoard
              ->on($board_id)
              ->group($id_group)
              ->deleteItem($item_id);



// Run a custom query
$query = '
boards (ids: 12121212) {
  groups (ids: group_id) {
    items {
      id
      name
      column_values {
        id
        text
        title
      }
    }
  }
}';

# For Query
$items = $MondayBoard->customQuery( $query );

# For Mutation
$items = $MondayBoard->customMutation( $query );