PHP code example of valota / my-content-client

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

    

valota / my-content-client example snippets


// Initialize your client
$myClient = new Valota\MyContentAPI\Client(_API_KEY, _API_SECRET);


// get basic information
$response =$myClient->information();

// Post
$postMessage = new Valota\MyContentAPI\PostMessage();
$postMessage->setTitle('Title'); 
$postMessage->setMessage('Message');
$postMessage->setMedia('/path/to/image.or.video.jpg'); 
$postMessage->setDisplayTime(10); //seconds 
$postMessage->setSchedule([["from"=>1670615272, "to"=>1680615273]]);
// All are optional, but post has to have at least one of title, message or media.
$response = $myClient->post($postMessage);
//$response will be id of the new message. e.g. 123

// Edit
$editMessage = new Valota\MyContentAPI\EditMessage(174);
$editMessage->setTitle('Edited title'); // empty string unsets
$editMessage->setMessage('Edited message'); // empty string unsets
$editMessage->setDisplayTime(0); // 0 unsets
$postMessage->setSchedule([]); // empty array unsets
// All are optional. Only changes the values that are set.
$response = $myClient->edit($editMessage);


// List all messages
$response =$myClient->list($archive = false, $page = null);

// Get one message
$response =$myClient->get($message_id);

// Archive a message
$response =$myClient->archive($message_id);

// Restore a message from the archive
$response =$myClient->restore($message_id);

// Delete a message permanently
$response =$myClient->delete($message_id);