PHP code example of topbroker / topbroker-php

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

    

topbroker / topbroker-php example snippets


use TopBroker\TopBrokerApi;
$topbroker = new TopBrokerApi('<insert_api_username_token_here>', '<insert_api_password_token_here>');

/** Get Estate List */ 
$topbroker->estates->getList([]);

/** Get Estate List Flat and Houses, 
 * Minimum 50 sq. m area, sort by price from highest to lowest  */
$topbroker->estates->getList([
  'estate_type' => ['house', 'flat'], 
  'area_min' => 50, 
  'sort_by' => 'price', 'sort_to' => 'desc',
  'per_page' => 10, 'page' => 1 ]);

/** Get Estate List By Custom Field */
$topbroker->estates->getList(['custom_fields' => [
  'c_f_e_zymos' => ['Discounted', 'Top']]
  ]);

$topbroker->estates->getCount(['user_id' => 123]);

$topbroker->estates->getCustomFields([]);

$topbroker->estates->getCustomViews([]);

$topbroker->estates->getRecordStatuses([]);

$topbroker->estates->getAttributes('commercial');
$topbroker->estates->getAttributes('flat');
$topbroker->estates->getAttributes('site');
$topbroker->estates->getAttributes('house');

$topbroker->estates->createItem([
  'estate_type' => 'flat', 
  'user_id' => 123, 
  'municipality_id' => 461,
  'city_id' => 1,
  'block_id' => 1,
  'street_id' => 22189,
  'area' => 68.2,
  'sale_price' => 125000,
  'floor' => 2,
  'floor_count' => 5,
  'room_count' => 3,
  'custom_fields' => [
    'c_f_c_tags' => ['Good location']
    ]);

$topbroker->estates->getItem(12345);

$topbroker->estates->updateItem(12345, [
  'name' => 'Johnny NewName', 
  'custom_fields' => ['c_f_c_company_name' => 'Company ABC']
  ]);

$topbroker->estates->getPhotos(12345);

$topbroker->estates->getMedia(12345);

$topbroker->estates->getNearbyPlaces(12345);

$topbroker->estates->changePrivacy(12345, ['privacy_level' => 'public']);

$topbroker->estates->changeOwner(12345, ['user_id' => 1]);

$topbroker->estates->deleteItem(12345);

$topbroker->locations->getMunicipalities([]);

/** List of cities located in specific municipality */
$topbroker->locations->getCities(['municipality_id' => 123]);

/** List of districts located in specific city */
$topbroker->locations->getBlocks(['city_id' => 123]);

/** List of street located in specific city, containing Flat type estates and minimum price 100K */
$topbroker->locations->getStreets([
  'city_id' => 123, 'for_sale ' => true, 
  'price_to' => 100000, 'estate_type' => ['flat']
  ]);

$topbroker->locations->getList([]);

$topbroker->locations->getItem(1234);

/** Get Contact List */
$topbroker->contacts->getList([]);

/** Get Contact List By User ID */
$topbroker->contacts->getList(['user_id' => 123]);

/** Get Contact List By Custom Field */
$topbroker->contacts->getList(['custom_fields' => [
  'c_f_c_company_name' => 'Company XYZ', 
  'c_f_c_company_size' => '5-10']
  ]);

$topbroker->contacts->getCount(['user_id' => 123]);

$topbroker->contacts->getCustomFields([]);

$topbroker->contacts->getRecordStatuses([]);

$topbroker->contacts->createItem([
  'name' => 'John Doe',
  'user_id' => 123, 
  'custom_fields' => [
    'c_f_c_company_name' => 'Company XYZ', 
    'c_f_c_company_size' => '5-10']
    ]);

$topbroker->contacts->getItem(12345);

$topbroker->contacts->updateItem(12345, [
  'name' => 'Johnny NewName', 
  'custom_fields' => ['c_f_c_company_name' => 'Company ABC']
  ]);

$topbroker->contacts->changeOwner(12345, ['user_id' => 1]);

$topbroker->contacts->changePrivacy(12345, ['privacy_level' => 'shared', 'user_ids' => [12, 34, 42]]);

$topbroker->contacts->deleteItem(12345);

/** Get Contact List */
$topbroker->inquiries->getList([]);

/** Get Contact List By User ID */
$topbroker->inquiries->getList(['user_id' => 123]);

/** Get Contact List By Custom Field */
$topbroker->inquiries->getList(['custom_fields' => [
  'c_f_i_special_needs' => 'Disco ball']
  ]);

$topbroker->inquiries->getCount([]);

$topbroker->inquiries->getCustomFields([]);

$topbroker->inquiries->getRecordStatuses([]);

$topbroker->inquiries->createItem([
  'estate_type' => 'house', 
  'title' => 'Hub','user_id' => 123, 
  'custom_fields' => [
    'c_f_i_special_needs' => ['Disco ball', 'Unicorn'], 
    'c_f_c_company_size' => '1-5']
    ]);

$topbroker->inquiries->getItem(12345);

$topbroker->inquiries->updateItem(12345, [
  'title' => 'Dev Hub', 
  'custom_fields' => ['c_f_c_company_name' => 'Startup XYZ']
  ]);

$topbroker->inquiries->changeOwner(12345, ['user_id' => 1]);

$topbroker->inquiries->changePrivacy(12345, ['privacy_level' => 'shared', 'user_ids' => [12, 34, 42]]);

$topbroker->inquiries->deleteItem(12345);

$topbroker->finances->getList(['user_id' => 12345]);

$topbroker->finances->getSum(['user_id' => 12345]);

$topbroker->finances->getIncomeGroups();

$topbroker->finances->getExpensesGroups();

$topbroker->deals->getList(['user_id' => 12345, 'finance_operation_type' => 'income']);

$topbroker->deals->getItem(12345);

$topbroker->deals->getCount(['estate_type' => ['flat']]);

$topbroker->deals->getAverage(['for_sale' => true]);

$topbroker->users->getList(['custom_fields' => ['c_f_u_visible_in_homepage' => 'Yes']]);

$topbroker->users->getItem(12345);

$topbroker->users->getCount([]);

$topbroker->users->getCustomFields([]);
sh
composer