From: Stricted Date: Sun, 26 Jul 2015 17:40:44 +0000 (+0200) Subject: add deletePhoneBookEntry X-Git-Tag: 1.0.4~5 X-Git-Url: https://git.stricted.de/?p=GitHub%2FStricted%2Fspeedport-hybrid-php-api.git;a=commitdiff_plain;h=5e5d7118702c686e2d2d25218dcf1a6ba16f85d5 add deletePhoneBookEntry --- diff --git a/SpeedportHybrid.class.php b/SpeedportHybrid.class.php index c5eed35..1c0e18f 100644 --- a/SpeedportHybrid.class.php +++ b/SpeedportHybrid.class.php @@ -271,6 +271,8 @@ class SpeedportHybrid { * @return array */ public function addPhoneBookEntry ($name, $firstname, $private, $work, $mobile, $id = -1) { + $this->checkLogin(); + $path = 'data/PhoneBook.json'; $fields = array( 'csrf_token' => $this->getToken(), @@ -280,12 +282,12 @@ class SpeedportHybrid { 'phonebook_vorname' => $firstname, 'phonebook_number_p' => $private, 'phonebook_number_a' => $work, - 'phonebook_number_m' => $mobile, - 'action' => '1' + 'phonebook_number_m' => $mobile ); $data = $this->sentRequest($path, $fields, true); $data = $this->getValues($data['body']); + if ($data['status'] == 'ok') { return $data; } @@ -310,6 +312,36 @@ class SpeedportHybrid { return $this->addPhoneBookEntry($name, $firstname, $private, $work, $private, $id); } + /** + * delete Phone Book Entry + * + * @param integer $id + * + * @return array + */ + public function deletePhoneBookEntry ($id) { + $this->checkLogin(); + + $path = 'data/PhoneBook.json'; + $fields = array( + 'csrf_token' => $this->getToken(), + 'id' => $id, + 'deleteEntry' => 'delete' + ); + + $data = $this->sentRequest($path, $fields, true); + $data = $this->getValues($data['body']); + print_r($data); + + if ($data['status'] == 'ok') { + return $data; + } + else { + throw new RouterException('can not delete Phone Book Entry'); + } + + } + /** * get uptime based on online (connection) time *