Brekeke Forum Index » Brekeke SIP Server Forum

Post new topic   Reply to topic
You are told by e-mail.
Author Message
makoto
Brekeke Member


Joined: 05 Sep 2012
Posts: 12
Location: JAPAN

PostPosted: Mon Sep 10, 2012 3:00 am    Post subject: You are told by e-mail. Reply with quote

1. Brekeke Product Name and version:
Brekeke SIP Server 2.4.8.6
2. Java version:
1.7.0_05
3. OS type and the version:
Linu 2.6.32-279.1.1.el6.x86_64
4. UA (phone), gateway or other hardware/software involved:

5. Select your network pattern from http://www.brekeke-sip.com/bbs/network/networkpatterns.html :
pattern1
6. Your problem:
Japanese was translated into English with translation software.
I think that there is a miswritten word.
Please read by warm heart.
:)

http://204.200.204.196/bbs_jp/viewtopic.php?t=8

When someone is called and there is no response, how to mail that there was a call is considered.
Made from PHP.
Will be displayed as "ERROR."
Back to top
View user's profile
makoto
Brekeke Member


Joined: 05 Sep 2012
Posts: 12
Location: JAPAN

PostPosted: Mon Sep 10, 2012 3:00 am    Post subject: Re: You are told by e-mail. Reply with quote

If "http://[userid]:[password]@localhost:[port]/path?query" is inputted by URL, it will be compulsorily sent to "http://localhost:[port]/gate?bean=sipadmin.web.Login".
* The right way of writing.
* The site etc. which are consulted.
Please let me know.

Thank you.
Back to top
View user's profile
davi
Brekeke Addict


Joined: 26 Jan 2011
Posts: 34

PostPosted: Mon Sep 10, 2012 10:29 am    Post subject: Reply with quote

Are you talking about Brekeke PBX's feature?
Back to top
View user's profile
makoto
Brekeke Member


Joined: 05 Sep 2012
Posts: 12
Location: JAPAN

PostPosted: Mon Sep 10, 2012 11:52 am    Post subject: Reply with quote

[quote="davi"]Are you talking about Brekeke PBX's feature?[/quote]

Thank you for your replay.

No.
I want to apply to SIP, the PHP that can be used in the PBX.
Back to top
View user's profile
davi
Brekeke Addict


Joined: 26 Jan 2011
Posts: 34

PostPosted: Mon Sep 10, 2012 12:30 pm    Post subject: Reply with quote

Do you want to receive an e-mail notification if a callee doesn't pick a call?

I know the following Brekeke PBX's API allows you to create such a feature.
http://www.brekeke-sip.com/download/bpbx/v3_x/bpbxv3_log_db_en.pdf
Back to top
View user's profile
makoto
Brekeke Member


Joined: 05 Sep 2012
Posts: 12
Location: JAPAN

PostPosted: Mon Sep 10, 2012 6:32 pm    Post subject: Reply with quote

> Do you want to receive an e-mail notification if a callee doesn't pick a call?

Yes.

> I know the following Brekeke PBX's API allows you to create such a feature.

Thank you for your information.
However, there is not MySQL in a SIP call log.
thinks by the method of running by PHP.

[code]
<?php
function http($url="http://[userid]:[password]@localhost:[port]/path?query", $method="GET", $headers="Brekeke", $post=array(""))
{
$URL = parse_url($url);
if (isset($URL['query'])) {
$URL['query'] = "?".$URL['query'];
} else {
$URL['query'] = "";
}
if (!isset($URL['port'])) $URL['port'] = 80;
$request = $method." ".$URL['path'].$URL['query']." HTTP/1.0\r\n";
$request .= "Host: ".$URL['host']."\r\n";
$request .= "User-Agent: PHP/".phpversion()."\r\n";
if (isset($URL['user']) && isset($URL['pass'])) {
$request .= "Authorization: Basic ".base64_encode($URL['user'].":".$URL['pass'])."\r\n";
}
$request .= $headers;
if (strtoupper($method) == "POST") {
while (list($name, $value) = each($post)) {
$POST[] = $name."=".urlencode($value);
}
$postdata = implode("&", $POST);
$request .= "Content-Type: application/x-www-form-urlencoded\r\n";
$request .= "Content-Length: ".strlen($postdata)."\r\n";
$request .= "\r\n";
$request .= $postdata;
} else {
$request .= "\r\n";
}
$fp = fsockopen($URL['host'], $URL['port']);
if (!$fp) {
die("ERROR\n");
}
fputs($fp, $request);
$response = "";
while (!feof($fp)) {
$response .= fgets($fp, 4096);
}
fclose($fp);
$DATA = split("\r\n\r\n", $response, 2);
echo "<!--\n".$request."\n-->\n";
echo "<!--\n".$DATA[0]."\n-->\n";
echo $DATA[1];
}
http("http://localhost:[port]/gate?bean=sipadmin.web.LogViewer&operation=html&ymd=20120903");
?>
[/code]
Back to top
View user's profile
Tata
Brekeke Master Guru


Joined: 27 Jan 2008
Posts: 223

PostPosted: Mon Sep 10, 2012 7:25 pm    Post subject: Reply with quote

Hi Makoto,
Please explain how the code works.
Back to top
View user's profile
makoto
Brekeke Member


Joined: 05 Sep 2012
Posts: 12
Location: JAPAN

PostPosted: Mon Sep 10, 2012 8:11 pm    Post subject: Reply with quote

> Please explain how the code works.

Thank you for your replay.
OK.

For example, suppose that I call you.
01: I => You
02: However, you are absent.
You is not answered.
03: PHP reads call log of Brekeke SIP Server.
PHP finds Cancel or Time out by result of call log.
04: PHP tells you about "makoto call you, September 11." by e-mail.
05: You could know the call from me by E-mail.
Back to top
View user's profile
makoto
Brekeke Member


Joined: 05 Sep 2012
Posts: 12
Location: JAPAN

PostPosted: Mon Sep 10, 2012 8:15 pm    Post subject: Reply with quote

[code]
<?php
/*
$url : URL which begins from http://( http://user:pass@host:port/path?query )
$method : GET, POST, or HEAD (a default is GET)
$headers : Arbitrary additional headers
$post : Arrangement which stored the data transmitted at the time of POST ("variable identifier" => "value")
*/
[/code]
Back to top
View user's profile
makoto
Brekeke Member


Joined: 05 Sep 2012
Posts: 12
Location: JAPAN

PostPosted: Mon Sep 10, 2012 8:17 pm    Post subject: Reply with quote

[code]
function http($url="http://[userid]:[password]@localhost:[port]/path?query", $method="GET", $headers="Brekeke", $post=array(""))
{
/* URL is decomposed */
$URL = parse_url($url);

/* Query */
if (isset($URL['query'])) {
$URL['query'] = "?".$URL['query'];
} else {
$URL['query'] = "";
}

/* A default port is 80 */
if (!isset($URL['port'])) $URL['port'] = 80;

/* Request line */
$request = $method." ".$URL['path'].$URL['query']." HTTP/1.0\r\n";

/* Request header */
$request .= "Host: ".$URL['host']."\r\n";
$request .= "User-Agent: PHP/".phpversion()."\r\n";

/* The header for Basic attestation */
if (isset($URL['user']) && isset($URL['pass'])) {
$request .= "Authorization: Basic ".base64_encode($URL['user'].":".$URL['pass'])."\r\n";
}

/* An additional header */
$request .= $headers;

/* A header is added at the time of POST.
The data which carried out URL encoding is attached to an end. */
if (strtoupper($method) == "POST") {
while (list($name, $value) = each($post)) {
$POST[] = $name."=".urlencode($value);
}
$postdata = implode("&", $POST);
$request .= "Content-Type: application/x-www-form-urlencoded\r\n";
$request .= "Content-Length: ".strlen($postdata)."\r\n";
$request .= "\r\n";
$request .= $postdata;
} else {
$request .= "\r\n";
}

/* Connects with a WEB server */
$fp = fsockopen($URL['host'], $URL['port']);

/* Processing when connection goes wrong */
if (!$fp) {
die("ERROR\n");
}

/* Demand data transmission */
fputs($fp, $request);

/* Response data reception */
$response = "";
while (!feof($fp)) {
$response .= fgets($fp, 4096);
}

/* Connection is ended */
fclose($fp);

/* A header portion and a body section are separated */
$DATA = split("\r\n\r\n", $response, 2);

/* A request header is commented out and it is an output */
echo "<!--\n".$request."\n-->\n";

/* A response header is commented out and it is an output */
echo "<!--\n".$DATA[0]."\n-->\n";

/* A message body is outputted */
echo $DATA[1];
}

http("http://localhost:[port]/gate?bean=sipadmin.web.LogViewer&operation=html&ymd=20120903");
/* Next, the schedule which puts in an e-mail transmitting script */

?>
[/code]

Thank you.
Back to top
View user's profile
Tata
Brekeke Master Guru


Joined: 27 Jan 2008
Posts: 223

PostPosted: Tue Sep 11, 2012 10:55 am    Post subject: Reply with quote

> Will be displayed as "ERROR."

From your PHP code, it seems the "ERROR" happens if the PHP program can not open the URL.
Make sure the URL is correct.



By the way, it seems your PHP program gets the call result through the web access.
Since PHP access will not be a real-time manner, I recommend you use the plugin which allow you to send an e-mail in real-time.

http://www.brekeke-sip.com/download/bss/bss_accountplugin_en.txt
You can use "eventSessionEnd()" as a trigger for sending an e-mail.
Back to top
View user's profile
makoto
Brekeke Member


Joined: 05 Sep 2012
Posts: 12
Location: JAPAN

PostPosted: Tue Sep 11, 2012 8:08 pm    Post subject: Reply with quote

Very match thank you.

> From your PHP code, it seems the "ERROR" happens if the PHP program can not open the URL.
> Make sure the URL is correct.

I know.
How should it input into URL? It thought.

> By the way, it seems your PHP program gets the call result through the web access.

Yes.

> Since PHP access will not be a real-time manner,

I know.
I'm looking for the software to run the PHP in real time.

> I recommend you use the plugin which allow you to send an e-mail in real-time.

Oh.......
Thank you for your information.
How do I process, such as subject and body etc?

Thank you.
Back to top
View user's profile
Tata
Brekeke Master Guru


Joined: 27 Jan 2008
Posts: 223

PostPosted: Tue Sep 11, 2012 10:46 pm    Post subject: Reply with quote

> How do I process, such as subject and body etc?

Refer to the plugin API document.
The event method "eventSessionEnd()" will be called just after a session closes.
If its result code is 2, it means the call has been canceled.

For composing an e-mail, refer to JavaMail API.
Back to top
View user's profile
makoto
Brekeke Member


Joined: 05 Sep 2012
Posts: 12
Location: JAPAN

PostPosted: Wed Sep 12, 2012 10:05 pm    Post subject: Reply with quote

Thank you for replay.
:)

> Refer to the plugin API document.
> For composing an e-mail, refer to JavaMail API.

I looked in the search engine, I can not find what it looked like.
Where is it?
Please tell us about the site.
Back to top
View user's profile
makoto
Brekeke Member


Joined: 05 Sep 2012
Posts: 12
Location: JAPAN

PostPosted: Wed Sep 12, 2012 10:50 pm    Post subject: Reply with quote

Perhaps, there is a need to create a plug-in, I tried to make Email.java.

[code]
package com.brekeke.net.sip.sv.session.plugins;

import com.brekeke.net.sip.sv.session.*;
import com.brekeke.net.sip.sv.session.plugins.*;

public void eventSessionEnd( EventStat evstat )
int sid;

String callid;

String username;
String usernameAuth;

String urlCaller;
String tagCaller;
AddrPort apCaller;

String urlCallee;
String tagCallee;
AddrPort apCallee;

String methodStart;
long seqStart;

String methodEnd;
long seqEnd;
int senderEnd;

long timeSessionStart;
long timeSessionEnd;
long timeTalkStart;
long timeTalkEnd;

int result;
int errorcode;

[Class name]......
[/code]

If i make it this way is correct, what may be the same as PHP is more writing this?
And this E-mail.java may be saved at a plug-in folder?

Dial plan is......

Matching Patterns
$request = ^INVITE
Deploy Patterns
$session = [Class name]
$continue = true
Back to top
View user's profile
Tata
Brekeke Master Guru


Joined: 27 Jan 2008
Posts: 223

PostPosted: Wed Sep 12, 2012 10:51 pm    Post subject: Reply with quote

This is the Session Plugin document.
http://www.brekeke-sip.com/download/bss/bss_accountplugin_en.txt

This is JavaMail API.
http://www.oracle.com/technetwork/java/javamail/index.html
Back to top
View user's profile
makoto
Brekeke Member


Joined: 05 Sep 2012
Posts: 12
Location: JAPAN

PostPosted: Wed Sep 12, 2012 11:27 pm    Post subject: Reply with quote

> This is the Session Plugin document.
http://www.brekeke-sip.com/download/bss/bss_accountplugin_en.txt
> This is JavaMail API.
http://www.oracle.com/technetwork/java/javamail/index.html

Thank you for guidance to site.

In these two, it will be beyond my understanding.
If it is you when good, do you show me "how it advances, makes and sets up" and the example of description, and get them?

I learn based on this example of description.
Back to top
View user's profile
makoto
Brekeke Member


Joined: 05 Sep 2012
Posts: 12
Location: JAPAN

PostPosted: Wed Sep 12, 2012 11:27 pm    Post subject: Reply with quote

If difficult, as suited first, it will be coped with by PHP.
How should it input in URL so that it can log in by "http://[localhost]:[port]/gate?bean=sipadmin.web.Login" without entering ID and a password? Please let me know.

Ex)
http://[ID].[Password]@[localhost]:[port]/gate?bean=sipadmin.web.Login

Thank you.
Back to top
View user's profile
ambrosio
Brekeke Master Guru


Joined: 27 Mar 2008
Posts: 215

PostPosted: Thu Sep 13, 2012 12:10 am    Post subject: Reply with quote

Have you tried this URL?
http://[ID]:[Password]@[localhost]:[port]/gate?bean=sipadmin.web.Login
Back to top
View user's profile
Tata
Brekeke Master Guru


Joined: 27 Jan 2008
Posts: 223

PostPosted: Thu Sep 13, 2012 9:35 am    Post subject: Reply with quote

> And this E-mail.java may be saved at a plug-in folder?

The JAR file must be located under
<SIP Server install_dir>\webapps\proxy\WEB-INF\lib
Back to top
View user's profile
Display posts from previous:   
Post new topic   Reply to topic    Brekeke Forum Index » Brekeke SIP Server Forum All times are GMT - 7 Hours
Page 1 of 1