PHP code example of superdesk / contentapi-sdk-php

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

    

superdesk / contentapi-sdk-php example snippets




use Superdesk\ContentApiSdk\ContentApiSdk;
use Superdesk\ContentApiSdk\Client\CurlClient;
use Superdesk\ContentApiSdk\Client\CurlApiClient;
use Superdesk\ContentApiSdk\Api\Authentication\OAuthPasswordAuthentication;

$genericClient = new CurlClient();
$authentication = new OAuthPasswordAuthentication($genericClient);
$authentication
    ->setClientId(API_CLIENT_ID)
    ->setUsername(API_USERNAME)
    ->setPassword(API_PASSWORD);
$apiClient = new CurlApiClient($genericClient, $authentication);
$contentApi = new ContentApiSdk($apiClient, API_HOST, API_PORT, API_PROTOCOL);




use Superdesk\ContentApiSdk\ContentApiSdk;

$contentApi = new ContentApiSdk(...);

$maxPerPage = 1;
$startPage = 1;

$items = $contentApi->getItems(array(), $startPage, $maxPerPage);

$items->getNbResults(); // Total items
$items->getMaxPerPage(); // Max results per age == $maxPerPage
$items->getNbPages(); // Total pages

bash
$ php composer.phar 
bash
$ php sample/default-client/example.php
bash
$ php composer.phar install --no-dev