[Logo] Serotonin Software Community
  [Search] Search   [Recent Topics] Recent Topics   [Hottest Topics] Hottest Topics   [Members]  Member Listing   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
HTTP send-retrieve / HTTP authenication  XML
Forum Index » M2M general discussion
Author Message
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
mlohbihler

Master
[Avatar]

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
mlohbihler

Master
[Avatar]

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
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
 
Forum Index » M2M general discussion
Go to:   
Powered by JForum 2.1.9 © JForum Team