PHP code example of google / cloud-iot
1. Go to this page and download the library: Download google/cloud-iot 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 / cloud-iot example snippets
use Google\Cloud\Iot\V1\DeviceManagerClient;
$deviceManager = new DeviceManagerClient();
$projectId = '[MY_PROJECT_ID]';
$location = 'us-central1';
$registryId = '[MY_REGISTRY_ID]';
$registryName = $deviceManager->registryName($projectId, $location, $registryId);
$devices = $deviceManager->listDevices($registryName);
foreach ($devices->iterateAllElements() as $device) {
printf('Device: %s : %s' . PHP_EOL,
$device->getNumId(),
$device->getId()
);
}