1. Go to this page and download the library: Download seamapi/seam 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/ */
seamapi / seam example snippets
$seam = new Seam\Seam();
$devices = $seam->devices->list();
// Set the SEAM_API_KEY environment variable
$seam = new Seam\Seam();
// Pass as an option to the constructor
$seam = new Seam\Seam(api_key: "your-api-key");
// Use the factory method
$seam = Seam\Seam::from_api_key("your-api-key");
// Set the SEAM_PERSONAL_ACCESS_TOKEN and SEAM_WORKSPACE_ID environment variables
$seam = new Seam\Seam();
// Pass as options to the constructor
$seam = new Seam\Seam(
personal_access_token: "your-personal-access-token",
workspace_id: "your-workspace-id"
);
// Use the factory method
$seam = Seam\Seam::from_personal_access_token(
"your-personal-access-token",
"your-workspace-id"
);
use Seam\ActionAttemptFailedError;
use Seam\ActionAttemptTimeoutError;
try {
$seam->locks->unlock_door(device_id: $device_id);
} catch (ActionAttemptFailedError $error) {
print "Could not unlock the door: " . $error->getMessage();
print "Error code: " . $error->getErrorCode();
} catch (ActionAttemptTimeoutError $error) {
print "The door did not unlock in time";
print "Action attempt: " . $error->getActionAttempt()->action_attempt_id;
}
use Seam\Resources\ActionAttempt\UnlockDoor;
$action_attempt = $seam->locks->unlock_door(
device_id: $device_id,
wait_for_action_attempt: false
);
if ($action_attempt instanceof UnlockDoor\Success) {
var_dump($action_attempt->result); // The result is populated here.
}
if ($action_attempt instanceof UnlockDoor\Error) {
print $action_attempt->error->message; // The error is populated here.
}
use Seam\NullValue;
// Leaves the name unchanged.
$seam->devices->update(device_id: $device_id, name: null);
// Unsets the name.
$seam->devices->update(device_id: $device_id, name: NullValue::NULL);
// Set the SEAM_PERSONAL_ACCESS_TOKEN environment variable
$seam = new Seam\SeamWithoutWorkspace();
// Use the factory method
$seam = Seam\SeamWithoutWorkspace::from_personal_access_token(
"your-personal-access-token"
);
// List workspaces authorized for this Personal Access Token
$workspaces = $seam->workspaces->list();
$workspace = $seam->workspaces->create(
name: "New Workspace",
connect_partner_name: "Your Company"
);
if ($action_attempt->status === "pending") {
// The action is still running.
}
use Seam\Resources\ActionAttempt\Status;
use Seam\Resources\Event\EventType;
if ($action_attempt->status === Status::PENDING->value) {
// The action is still running.
}
$status = Status::tryFrom($action_attempt->status);
$event_type = EventType::tryFrom($event->event_type);
$seam = new Seam\Seam(endpoint: "https://example.com");