| Author |
Message |
![[Post New]](/forum/templates/default/images/icon_minipost_new.gif) 15/01/2010 03:54:16
|
pegi
Initiate
Joined: 13/01/2010 02:48:45
Messages: 8
Offline
|
Hi.
I'm trying to connect to a PLC device that communicate like this:
To get values:
- Send "http://url/filename?param=<p1>;<p2>;<p3>"
(This will get me a file containing the values I asked for separated with semicolon)
To set values:
- Send "http://url/filename?param=<p1>,val;<p2>,val;<p3>,val"
(This will get me a file containing OK if all went well)
To get the device to accept this I must be able to do HTTP authentication.
Can I get this to work with Mango?
Is it possible to only send messages if set values are changed?
/P
|
|
|
 |
![[Post New]](/forum/templates/default/images/icon_minipost_new.gif) 19/01/2010 21:33:12
|
mlohbihler
Master
![[Avatar]](/forum/images/avatar/eccbc87e4b5ce2fe28308fd9f2a7baf3.png)
Joined: 01/03/2007 22:48:52
Messages: 1456
Offline
|
Hi pegi,
You currently can get the values by using an HTTP Retriever data source and a bit of regex. But that data source doesn't have an option to set values.
|
Best regards,
Matthew Lohbihler |
|
|
 |
![[Post New]](/forum/templates/default/images/icon_minipost_new.gif) 19/01/2010 21:34:45
|
mlohbihler
Master
![[Avatar]](/forum/images/avatar/eccbc87e4b5ce2fe28308fd9f2a7baf3.png)
Joined: 01/03/2007 22:48:52
Messages: 1456
Offline
|
Oh, but, that data source doesn't currently support http authentication. In particular using the "http://username:password@domain/path" doesn't work with the HTTPClient package, which is what Mango uses.
|
Best regards,
Matthew Lohbihler |
|
|
 |
![[Post New]](/forum/templates/default/images/icon_minipost_new.gif) 20/01/2010 02:47:30
|
pegi
Initiate
Joined: 13/01/2010 02:48:45
Messages: 8
Offline
|
Ok thanks.
In the meantime I found a workaround for this trough my PHP server that can deal with HTTP Auth.
The function I found:
--------------------------------------------------------------
function http_auth_get($url,$username,$password){
$cred = sprintf('Authorization: Basic %s',base64_encode("$username:$password") ;
$opts = array(
'http'=>array(
// 'proxy' => 'tcp://www.proxy.com:80',
// 'request_fulluri' => True,
'method'=>'GET',
'header'=>$cred)
);
$ctx = stream_context_create($opts);
$handle = fopen ( $url, 'r', false,$ctx);
return stream_get_contents($handle);
}
--------------------------------------------------------------
I just made a simple script that routes requests through this.
/P
|
|
|
 |
|
|