I recommend using Guzzle.
http://docs.guzzlephp.org/en/stable/ Guzzle, PHP HTTP client — Guzzle Documentation<http://docs.guzzlephp.org/en/stable/> docs.guzzlephp.org Guzzle Documentation¶ Guzzle is a PHP HTTP client that makes it easy to send HTTP requests and trivial to integrate with web services. Simple interface for building ... ________________________________ Fra: Kea-users <[email protected]> på vegne av [email protected] <[email protected]> Sendt: 9. februar 2018 08:54:10 Til: [email protected] Emne: Kea-users Digest, Vol 44, Issue 6 Send Kea-users mailing list submissions to [email protected] To subscribe or unsubscribe via the World Wide Web, visit https://lists.isc.org/mailman/listinfo/kea-users or, via email, send a message with subject or body 'help' to [email protected] You can reach the person managing the list at [email protected] When replying, please edit your Subject line so it is more specific than "Re: Contents of Kea-users digest..." Today's Topics: 1. kea-ctrl-agent - request by php/curl (Zayer, Sebastian) 2. Re: kea-ctrl-agent - request by php/curl (Marcin Siodelski) 3. Support Request (Evren Yilmaz) ---------------------------------------------------------------------- Message: 1 Date: Thu, 8 Feb 2018 14:35:05 +0000 From: "Zayer, Sebastian" <[email protected]> To: "KEA-Users ([email protected])" <[email protected]> Subject: [Kea-users] kea-ctrl-agent - request by php/curl Message-ID: <[email protected]> Content-Type: text/plain; charset="us-ascii" Hey there, i'm trying to control the kea server by using the control agent. I already implemented a web-frontend to the database (mysql) to show all the leases and reservations. Now I'm trying to get the running configuration by requesting the control agent. $msg = array("command" => "config-get", "service" => "[ dhcp4 ]"); $message = json_encode($msg); //$message = '{ "command": "config-get", "service": "dhcp4" }'; $len = strlen($message); echo print_r($message, true), "\n"; $ch = curl_init('http://127.0.0.1:8080/'); curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_POSTFIELDS, $message); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Content-type: application/json', 'Content-Length: '. $len) ); curl_setopt($ch, CURLOPT_TIMEOUT, 10); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); $ret = curl_exec($ch); if($ret === false) { echo 'Curl error: ' . curl_error($ch); } else { echo print_r($ret, true); echo 'Operation completed without any errors'; } All I receive is the following: {"command":"config-get","service":"[ dhcp4 ]"} { "result": 400, "text": "Bad Request" } Operation completed without any errors I tried a lot of things: - dhcp4 with or without brackets - using the documented string (http://kea.isc.org/docs/kea-guide.html#ctrl-channel-client) - with and without timeouts - different HTTPHEADER (with, and without Content-Length like in the documentation) The service is up and running, if i'm using the shell and curl the example works. I also tried to get a clue by reading the log (DEBUG, Level 99) but there is just a lousy message "HTTP_DATA_RECEIVED received 152 bytes from 127.0.0.1" and "DEBUG [kea-ctrl-agent.http] HTTP_RESPONSE_SEND sending HTTP response HTTP/1.1 400 Bad Request#015#012 to 127.0.0.1" Does anybody have a clue how to successfully connect and receive a proper message? Thanks in advance Sebastian -------------- next part -------------- An HTML attachment was scrubbed... URL: <https://lists.isc.org/pipermail/kea-users/attachments/20180208/69c7827c/attachment-0001.html> ------------------------------ Message: 2 Date: Thu, 8 Feb 2018 17:13:07 +0100 From: Marcin Siodelski <[email protected]> To: "Zayer, Sebastian" <[email protected]>, "KEA-Users ([email protected])" <[email protected]> Subject: Re: [Kea-users] kea-ctrl-agent - request by php/curl Message-ID: <[email protected]> Content-Type: text/plain; charset=windows-1252 I am hoping that the only thing that you have to correct is to do this: "service" => [ "dhcp4" ] rather than "service" => "[ dhcp4 ]" Marcin Siodelski ISC On 08.02.2018 15:35, Zayer, Sebastian wrote: > Hey there, > > ? > > i?m trying to control the kea server by using the control agent. > > ? > > I already implemented a web-frontend to the database (mysql) to show all > the leases and reservations. > > Now I?m trying to get the running configuration by requesting the > control agent. > > ? > > $msg = array("command" => "config-get", "service" => "[ dhcp4 ]"); > > $message = json_encode($msg); > > ? > > //$message = '{ "command": "config-get", "service": "dhcp4" }'; > > $len = strlen($message); > > ? > > echo print_r($message, true), "\n"; > > ? > > $ch = curl_init('http://127.0.0.1:8080/'); > > curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); > > curl_setopt($ch, CURLOPT_POSTFIELDS, $message); > > curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); > > curl_setopt($ch, CURLOPT_HTTPHEADER, array( > > ???? 'Content-type: application/json', > > ???? 'Content-Length: '. $len) > > ); > > curl_setopt($ch, CURLOPT_TIMEOUT, 10); > > curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); > > ? > > $ret = curl_exec($ch); > > if($ret === false) > > { > > ??? echo 'Curl error: ' . curl_error($ch); > > } > > else > > { > > ???? echo print_r($ret, true); > > ??? echo 'Operation completed without any errors'; > > } > > ? > > All I receive is the following: > > {"command":"config-get","service":"[ dhcp4 ]"} > > { "result": 400, "text": "Bad Request" } > > Operation completed without any errors > > ? > > ? > > I tried a lot of things: > > -?????? dhcp4 with or without brackets > > -?????? using the documented string > (http://kea.isc.org/docs/kea-guide.html#ctrl-channel-client) > > -?????? with and without timeouts > > -?????? different HTTPHEADER (with, and without Content-Length like in > the documentation) > > ? > > The service is up and running, if i?m using the shell and curl the > example works. > > I also tried to get a clue by reading the log (DEBUG, Level 99) but > there is just a lousy message ?HTTP_DATA_RECEIVED received 152 bytes > from 127.0.0.1? and ?DEBUG [kea-ctrl-agent.http] HTTP_RESPONSE_SEND > sending HTTP response HTTP/1.1 400 Bad Request#015#012 to?*127.0.0.1*? > > ? > > Does anybody have a clue how to successfully connect and receive a > proper message? > > ? > > ? > > Thanks in advance > > ? > > Sebastian > > > > _______________________________________________ > Kea-users mailing list > [email protected] > https://lists.isc.org/mailman/listinfo/kea-users > ------------------------------ Message: 3 Date: Fri, 9 Feb 2018 08:54:04 +0100 From: "Evren Yilmaz" <[email protected]> To: <[email protected]> Subject: [Kea-users] Support Request Message-ID: <[email protected]> Content-Type: text/plain; charset="iso-8859-1" Hi Guys, After some testing time I installed Kea 1.2 and it runs on Debian 8. We ordered the forensic hook and I got a Zip File -> but I dont have any Idea how to install it. Also not found a documentation about this. And my second Question: Is There also a guide how to upgrade from 1.2 to 1.3 without losing lease informations from Database? Also not found anything. Sorry Im really newbie with KEA and needs someone who have little bit more experience. Freundliche Gr?sse Evren Yilmaz System Engineer Bestens bedient, bestens vernetzt STADTANTENNEN AG Bachweid 20 6340 Baar Tel Zen.: +41 41 766 70 70 Tel direkt: +41 41 766 70 89 Fax: +41 41 766 70 76 E-Mail: <mailto:[email protected]> [email protected] <http://www.stagbaar.ch/> www.stagbaar.ch<http://www.stagbaar.ch> <http://www.databaar.ch/> www.databaar.ch<http://www.databaar.ch> <https://www.facebook.com/Databaar-1167042370091761/> <https://www.instagram.com/databaar_official/> -------------- next part -------------- An HTML attachment was scrubbed... URL: <https://lists.isc.org/pipermail/kea-users/attachments/20180209/84af5607/attachment.html> -------------- next part -------------- A non-text attachment was scrubbed... Name: image001.png Type: image/png Size: 8595 bytes Desc: not available URL: <https://lists.isc.org/pipermail/kea-users/attachments/20180209/84af5607/attachment.png> -------------- next part -------------- A non-text attachment was scrubbed... Name: image002.jpg Type: image/jpeg Size: 15204 bytes Desc: not available URL: <https://lists.isc.org/pipermail/kea-users/attachments/20180209/84af5607/attachment.jpg> -------------- next part -------------- A non-text attachment was scrubbed... Name: image003.jpg Type: image/jpeg Size: 14776 bytes Desc: not available URL: <https://lists.isc.org/pipermail/kea-users/attachments/20180209/84af5607/attachment-0001.jpg> ------------------------------ Subject: Digest Footer _______________________________________________ Kea-users mailing list [email protected] https://lists.isc.org/mailman/listinfo/kea-users ------------------------------ End of Kea-users Digest, Vol 44, Issue 6 ****************************************
_______________________________________________ Kea-users mailing list [email protected] https://lists.isc.org/mailman/listinfo/kea-users
