UserService Plugin extension

Document created by uvigii on May 19, 2008Last modified by uvigii on Apr 19, 2010
Version 2Show Document
  • View in full screen mode

I want to be able to send messages from external application via http request to users, so I 'merged' UserService and Subscription plugins. With this modification userService can send messages to users. All you need to do is to build correct http request in your application.

  • Note that I'm NOT a Java programmer at all!

  • In order to use this modification You need to reinstall userService Plugin.

  • No error handling at all.

 

New parameters were added:

sender

sender of message

OF version

recipient

recipient of message

3.6+

subject

subject of message

3.6+

msg

body (text) of message

3.6+

username

some valid username

3.7+

 

Example query 3.6+ :

http://example.com:9090/plugins/userService/userservice?secret=bigsecret&type=se ndmsg&sender=admin1&recipient=user1&subject=test_msg&msg=my_important_message

Example query 3.7+ :

http://example.com:9090/plugins/userService/userservice?secret=bigsecret&type=se ndmsg&sender=admin1&recipient=user1&subject=test_msg&msg=my_important_message&us ername=sysuser1

 

All parameters can be sent via HTTP POST or GET methods in single query. As example sender,recipient and subject via http GET, msg via POST method.

Note: In order to send big (more than ~2k) messages you need to use POST method for msg parameter.  You need to urlencode() some or all of values!

 

An example usage is intranet web application that sends message to user  when someone open a link. Simple PHP example:

// OF server address
$jserver='http://example.com:9090/plugins/userService/userservice';
//1
$postdata = http_build_query(
            array(
             'type'        => 'sendmsg',
             'secret'        => 'bigsecret',
             'username'     => 'sysuser1',    
             'msg'         => 'Call me ASAP',
             'sender'        => 'admin1',
             'recipient'    => 'user1',
             'subject'        => 'URGENT'
              )
);
//2
$opts = array('http' =>
            array(
            'method'  => 'POST',
            'header'  => 'Content-type: application/x-www-form-urlencoded',
            'content' => $postdata
            )
);
//3
$context  = stream_context_create($opts);
//Send message & Get result
$line = file_get_contents($jserver, false, $context);
//Check result
if (!(stripos($line, "<result>ok</result>") === false)){Do something - message sent}

Outcomes