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 <kea-users-boun...@lists.isc.org> på vegne av 
kea-users-requ...@lists.isc.org <kea-users-requ...@lists.isc.org>
Sendt: 9. februar 2018 08:54:10
Til: kea-users@lists.isc.org
Emne: Kea-users Digest, Vol 44, Issue 6

Send Kea-users mailing list submissions to
        kea-users@lists.isc.org

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
        kea-users-requ...@lists.isc.org

You can reach the person managing the list at
        kea-users-ow...@lists.isc.org

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" <sebastian.za...@takko.de>
To: "KEA-Users (kea-users@lists.isc.org)" <kea-users@lists.isc.org>
Subject: [Kea-users] kea-ctrl-agent - request by php/curl
Message-ID: <995afaae445f4d7e882628e359a22...@takko.de>
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 <mar...@isc.org>
To: "Zayer, Sebastian" <sebastian.za...@takko.de>, "KEA-Users
        (kea-users@lists.isc.org)" <kea-users@lists.isc.org>
Subject: Re: [Kea-users] kea-ctrl-agent - request by php/curl
Message-ID: <3c4a205e-700a-8cec-09a9-d8c487a76...@isc.org>
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
> Kea-users@lists.isc.org
> https://lists.isc.org/mailman/listinfo/kea-users
>



------------------------------

Message: 3
Date: Fri, 9 Feb 2018 08:54:04 +0100
From: "Evren Yilmaz" <e...@stagbaar.ch>
To: <kea-users@lists.isc.org>
Subject: [Kea-users] Support Request
Message-ID: <001201d3a17b$27a80b10$76f82130$@stagbaar.ch>
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:e.yil...@databaar.ch> e.yil...@databaar.ch

 <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
Kea-users@lists.isc.org
https://lists.isc.org/mailman/listinfo/kea-users


------------------------------

End of Kea-users Digest, Vol 44, Issue 6
****************************************
_______________________________________________
Kea-users mailing list
Kea-users@lists.isc.org
https://lists.isc.org/mailman/listinfo/kea-users

Reply via email to