PHP code example of athlan / press-server-api-client

1. Go to this page and download the library: Download athlan/press-server-api-client 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/ */

    

athlan / press-server-api-client example snippets



use GuzzleHttp\Psr7\ServerRequest;
use PressServerApi\Callback\OperationInterface;
use PressServerApi\Callback\Operation\Factory\Psr7Request\OperationsFromRequestFactory;
use PressServerApi\Callback\Operation\Factory\OperationFactoryInterface;
use PressServerApi\Callback\Operation\Factory\AnnouncementOperationFactory;
use PressServerApi\Callback\Operation\Factory\AnnouncementDeleteOperationFactory;
use PressServerApi\Callback\Operation\Factory\AnnouncementPhotoOperationFactory;
use PressServerApi\Callback\Operation\Factory\AnnouncementPhotoDeleteOperationFactory;
use PressServerApi\Callback\Operation\Factory\CategoryOperationFactory;
use PressServerApi\Callback\Operation\Factory\CategoryDeleteOperationFactory;
use PressServerApi\Callback\Operation\Factory\UnknownOperationFactory;
use PressServerApi\Callback\OperationGroupProcessingResult;
use PressServerApi\Callback\OperationProcessingResult;
use PressServerApi\Callback\Response\ProcessingResultResponseFactory;
use PressServerApi\Callback\Response\Psr7Response\ProcessingResultResponseFactory as ProcessingResultPsr7ResponseFactory;

use Example\EventStore\Event;
use Example\EventStore\EventStoreInterface;
use Example\EventStore\SimpleFilesystemEventStore;
use Example\EventStore\Exception\EventAlreadyInStoreException;

use function QuimCalpe\ResponseSender\send AS send_response;

events from 3rd party callback
    try {
        $eventStore->store(new Event($operation->getOperationKey(), $operation));
    }
    catch(EventAlreadyInStoreException $e) {
    }

    // after processing, create the OperarionProcessingResult (success or failure)
    $result = OperationProcessingResult::createResultSuccess($operation);
    $results->addResult($result);
}

// Step 3. Prepare response.
$response = $responseFactoryPsr7->createProcessingResultResponse($results);

// Step 4. Send response.
return send_response($response);