angeck Posté(e) le 1 novembre 2013 Partager Posté(e) le 1 novembre 2013 Bonjour, Je recherche partout un moyen d'activer et désactiver les enregistrements (via requête http) de ma cam branchée sur surveillance station. J'ai trouvé des scripts que j'enregistre sur mon nas dans le dossier web mais ça ne marche pas ... ---------------------------------------------- <?php /* This script is an example of using curl in php to log into on one page and then get another page passing all cookies from the first page along with you. */ $ch = curl_init(); curl_setopt($ch, CURLOPT_COOKIEJAR, "/tmp/SS-session_cookie"); curl_setopt($ch, CURLOPT_URL,"ip:5000/webapi/auth.cgi?api=SYNO.API.Auth&method=Login&version=1&account=usert&passwd=pass&session=SurveillanceStation"); curl_exec ($ch); curl_close ($ch); unset($ch); $ch = curl_init(); curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); curl_setopt($ch, CURLOPT_COOKIEFILE, "/tmp/SS-session_cookie"); curl_setopt($ch, CURLOPT_URL,"ip:5000/webapi/SurveillanceStation/extrecord.cgi?api=SYNO.SurveillanceStation.ExternalRecording&method=Record&version=1&cameraId=1&action=start"); curl_exec ($ch); curl_close ($ch); unset($ch); $ch = curl_init(); curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); curl_setopt($ch, CURLOPT_COOKIEFILE, "/tmp/SS-session_cookie"); curl_setopt($ch, CURLOPT_URL,"ip:5000/webapi/auth.cgi?api=SYNO.API.Auth&method=Logout&version=1&session=SurveillanceStation"); curl_exec ($ch); curl_close ($ch); unset($ch); ?> Si je lance ce script (ip/rec_on.php) j'ai le message suivant : {"success":true} ---------------------------------------------- <?php //authentification $response = get_web_page("http://ip:5000/webapi/auth.cgi?api=SYNO.API.Auth&method=Login&version=2&account=user&passwd=pass&session=SurveillanceStation&format=sid"); //echo $response; $resArr = array(); $resArr = ($response); $resArr = json_decode($response,true); //sid in the array $sid=array(); $sid=$resArr[data]; //echo $sid[sid]; //send Start record $response = get_web_page("http://ip:5000/webapi/SurveillanceStation/extrecord.cgi?api=SYNO.SurveillanceStation.ExternalRecording&method=Record&version=1&cameraId=1&action=start&_sid=".$sid[sid]); echo $response; function get_web_page($url) { $options = array (CURLOPT_RETURNTRANSFER => true, // return web page CURLOPT_HEADER => false, // don't return headers CURLOPT_FOLLOWLOCATION => true, // follow redirects CURLOPT_ENCODING => "", // handle compressed CURLOPT_USERAGENT => "test", // who am i CURLOPT_AUTOREFERER => true, // set referer on redirect CURLOPT_CONNECTTIMEOUT => 120, // timeout on connect CURLOPT_TIMEOUT => 120, // timeout on response CURLOPT_MAXREDIRS => 10 ); // stop after 10 redirects $ch = curl_init ( $url ); curl_setopt_array ( $ch, $options ); $content = curl_exec ( $ch ); $err = curl_errno ( $ch ); $errmsg = curl_error ( $ch ); $header = curl_getinfo ( $ch ); $httpCode = curl_getinfo ( $ch, CURLINFO_HTTP_CODE ); curl_close ( $ch ); $header ['errno'] = $err; $header ['errmsg'] = $errmsg; $header ['content'] = $content; return $header ['content']; } ?> Si je lance ce script (ip/rec_on.php) j'ai le message suivant : {"error":{"code":400},"success":false} ---------------------------------------------- Mais rien ne se passe... surveillance station ne bouge pas. Je ne change que l'ip, user et pass... Merci de votre aide. 0 Citer Lien vers le commentaire Partager sur d’autres sites More sharing options...
Messages recommandés
Rejoindre la conversation
Vous pouvez publier maintenant et vous inscrire plus tard. Si vous avez un compte, connectez-vous maintenant pour publier avec votre compte.