Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?
- // Configuration
- $user = "username"; // Synology username with rights to Surveillance station
- $pass = "password"; // Password of the user entered above
- $ip = "10.0.0.250"; // IP-Adress of your Synology-NAS
- $port = "5000"; // default port of Surveillance Station
- $http = "http"; // Change to https if you use a secure connection
- $cameraID = "3"; // ID of the camera for taking snapshots
- $cameraStream = $_GET["stream"];
- // You can change the stream by adding ?stream=0/1/2 to the url. For example: www.yourdomain.com/snapshot.php?stream=2
- // 0: Live stream | 1: Recording stream | 2: Mobile stream
- // Default value is stream 0
- if ($cameraStream == NULL) {
- $cameraStream = "0";
- }
- // Authenticate with Synology Surveillance Station WebAPI and get our SID
- $json = file_get_contents($http.'://'.$ip.':'.$port.'/webapi/auth.cgi?api=SYNO.API.Auth&method=Login&version=3&account='.$user.'&passwd='.$pass.'&session=SurveillanceStation&format=sid');
- $obj = json_decode($json, true);
- @$sid = $obj["data"]["sid"];
- // Setting the correct header so the PHP file will be recognised as a JPEG file
- header('Content-Type: image/jpeg');
- // Read the contents of the snapshot and output it directly without putting it in memory first
- readfile($http.'://'.$ip.':'.$port.'/webapi/entry.cgi?camStm='.$cameraStream.'&version=3&cameraId='.$cameraID.'&api=SYNO.SurveillanceStation.Camera&preview=false&method=GetSnapshot&_sid='.$sid);
- // Log out from Surveillance Station
- file_get_contents($http.'://'.$ip.':'.$port.'/webapi/auth.cgi?api=SYNO.API.Auth&method=Logout&version=3&session=SurveillanceStation&_sid='.$sid);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement