PHP code example of wyz / practicalafas

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

    

wyz / practicalafas example snippets


use PracticalAfas\Connection;
use PracticalAfas\Client\RestCurlClient;
// This can be changed to SoapAppClient.
// Below 2 options are n example got calling a Get connector with simple filter, returning an
// array of data rows:
$result_as_array = $connection->getData('MyGetConnectorName',  [ 'SomeCategory' => 'CategName' ] );

// A more elaborate example of filtering/sorting, and returning the response
// value as a string (JSON for REST client, or XML for SOAP client).
$result_as_string = $connection->getData(
  'MyGetConnectorName',
  [ 'SomeCategory' => 'CategName',
    [ 'Updated' => '2017-01-01T16:00:00', '#op' => Connection::OP_LARGER_THAN ],
  ],
  Connection::GET_FILTER_AND,
  [ 'take' => 1000,
    'orderbyfieldids' => '-Updated',
    'options' => ['Outputmode' => Connection::GET_OUTPUTMODE_LITERAL ]
  ]
);

// Get a 'subject' (data blob):
$attachment = $connection->getData(123, [], Connection::DATA_TYPE_SUBJECT);

// This inserts a new organisation with only its name populated:
$connection->sendData(['name' => 'MyCompany Ltd.'], 'KnOrganisation', 'insert');

use PracticalAfas\Client\RestCurlClient;
// Below 2 options are n' => '64CHARS' ] );

// Equivalent of above Connection::getData() example:
$result_as_json_string = $client->callAfas(
  'GET',
  'connectors/MyGetConnectorName',
  [ 'take' => 1000,
    'filterfieldids' => 'SomeCategory,Updated',
    'filtervalues' => 'CategName,2017-01-01T16:00:00',
    'operatortypes' => '1,4',
    'orderbyfieldids' => '-Updated'
  ]
);

// Get a 'subject' (data blob):
$attachment = $client->callAfas('GET', 'subjectconnector/123');

// Equivalent of above Connection::sendData() example:
$client->callAfas('POST', 'connectors/KnOrganisation', [], json_encode([
  'KnOrganisation' => [
    'Element' => [
      'Fields' => [
       'MatchOga' => 0,
       'Nm' => 'MyCompany Ltd.',
  ]]]]
));

use PracticalAfas\Client\SoapAppClient;
// Below 2 options are n' => '64CHARS' ] );

// Equivalent of above Connection::getData() example:
$result_as_xml_string = $client->callAfas(
  'get',
  'GetDataWithOptions',
  [ 'connectorId' => 'MyGetConnectorName',
    'take' => 1000,
    'filtersXml' => '<Filters><Filter><Field FieldId="SomeCategory" OperatorType="1">CategName</Field>
      <Field FieldId="Updated" OperatorType="4">2017-01-01T16:00:00</Field></Filter></Filters>',
    'options' => '<options><Index><Field FieldId="Updated" OperatorType="0"/></Index>
      <Outputoptions>3</Outputoptions><Outputmode>1</Outputmode><Metadata>0</Metadata></options>',
  ]
);

// Get a 'subject' (data blob):
$attachment = $client->callAfas('subject', 'GetAttachment', [ 'subjectID' => 123 ] );

// Equivalent of above Connection::sendData() example:
$client->callAfas('update', 'Execute', [ 'connectorType' => 'KnOrganisation', 'dataXml' =>
 '<KnOrganisation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><Element><Fields Action="insert"><MatchOga>0</MatchOga><Nm>MyCompany Ltd.</Nm></Fields></Element></KnOrganisation>' ]
);