PHP code example of google / apps-chat

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

    

google / apps-chat example snippets


use Google\ApiCore\ApiException;
use Google\Apps\Chat\V1\Attachment;
use Google\Apps\Chat\V1\Client\ChatServiceClient;
use Google\Apps\Chat\V1\GetAttachmentRequest;

// Create a client.
$chatServiceClient = new ChatServiceClient();

// Prepare the request message.
$request = (new GetAttachmentRequest())
    ->setName($formattedName);

// Call the API and handle any network failures.
try {
    /** @var Attachment $response */
    $response = $chatServiceClient->getAttachment($request);
    printf('Response data: %s' . PHP_EOL, $response->serializeToJsonString());
} catch (ApiException $ex) {
    printf('Call failed with message: %s' . PHP_EOL, $ex->getMessage());
}