Author |
Message |
makoto Brekeke Member
![](images/spacer.gif)
Joined: 05 Sep 2012 Posts: 12
Location: JAPAN
|
Posted: Mon Sep 10, 2012 3:00 am Post subject: You are told by e-mail. |
|
|
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 |
|
makoto Brekeke Member
![](images/spacer.gif)
Joined: 05 Sep 2012 Posts: 12
Location: JAPAN
|
Posted: Mon Sep 10, 2012 3:00 am Post subject: Re: You are told by e-mail. |
|
|
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 |
|
davi Brekeke Addict
![](images/spacer.gif)
Joined: 26 Jan 2011 Posts: 34
|
Posted: Mon Sep 10, 2012 10:29 am Post subject: |
|
|
Are you talking about Brekeke PBX's feature? |
|
Back to top |
|
makoto Brekeke Member
![](images/spacer.gif)
Joined: 05 Sep 2012 Posts: 12
Location: JAPAN
|
Posted: Mon Sep 10, 2012 11:52 am Post subject: |
|
|
[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 |
|
davi Brekeke Addict
![](images/spacer.gif)
Joined: 26 Jan 2011 Posts: 34
|
|
Back to top |
|
makoto Brekeke Member
![](images/spacer.gif)
Joined: 05 Sep 2012 Posts: 12
Location: JAPAN
|
Posted: Mon Sep 10, 2012 6:32 pm Post subject: |
|
|
> 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 |
|
Tata Brekeke Master Guru
![](images/spacer.gif)
Joined: 27 Jan 2008 Posts: 223
|
Posted: Mon Sep 10, 2012 7:25 pm Post subject: |
|
|
Hi Makoto,
Please explain how the code works. |
|
Back to top |
|
makoto Brekeke Member
![](images/spacer.gif)
Joined: 05 Sep 2012 Posts: 12
Location: JAPAN
|
Posted: Mon Sep 10, 2012 8:11 pm Post subject: |
|
|
> 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 |
|
makoto Brekeke Member
![](images/spacer.gif)
Joined: 05 Sep 2012 Posts: 12
Location: JAPAN
|
Posted: Mon Sep 10, 2012 8:15 pm Post subject: |
|
|
[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 |
|
makoto Brekeke Member
![](images/spacer.gif)
Joined: 05 Sep 2012 Posts: 12
Location: JAPAN
|
Posted: Mon Sep 10, 2012 8:17 pm Post subject: |
|
|
[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 |
|
Tata Brekeke Master Guru
![](images/spacer.gif)
Joined: 27 Jan 2008 Posts: 223
|
Posted: Tue Sep 11, 2012 10:55 am Post subject: |
|
|
> 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 |
|
makoto Brekeke Member
![](images/spacer.gif)
Joined: 05 Sep 2012 Posts: 12
Location: JAPAN
|
Posted: Tue Sep 11, 2012 8:08 pm Post subject: |
|
|
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 |
|
Tata Brekeke Master Guru
![](images/spacer.gif)
Joined: 27 Jan 2008 Posts: 223
|
Posted: Tue Sep 11, 2012 10:46 pm Post subject: |
|
|
> 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 |
|
makoto Brekeke Member
![](images/spacer.gif)
Joined: 05 Sep 2012 Posts: 12
Location: JAPAN
|
Posted: Wed Sep 12, 2012 10:05 pm Post subject: |
|
|
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 |
|
makoto Brekeke Member
![](images/spacer.gif)
Joined: 05 Sep 2012 Posts: 12
Location: JAPAN
|
Posted: Wed Sep 12, 2012 10:50 pm Post subject: |
|
|
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 |
|
Tata Brekeke Master Guru
![](images/spacer.gif)
Joined: 27 Jan 2008 Posts: 223
|
|
Back to top |
|
makoto Brekeke Member
![](images/spacer.gif)
Joined: 05 Sep 2012 Posts: 12
Location: JAPAN
|
|
Back to top |
|
makoto Brekeke Member
![](images/spacer.gif)
Joined: 05 Sep 2012 Posts: 12
Location: JAPAN
|
Posted: Wed Sep 12, 2012 11:27 pm Post subject: |
|
|
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 |
|
ambrosio Brekeke Master Guru
![](images/spacer.gif)
Joined: 27 Mar 2008 Posts: 215
|
|
Back to top |
|
Tata Brekeke Master Guru
![](images/spacer.gif)
Joined: 27 Jan 2008 Posts: 223
|
Posted: Thu Sep 13, 2012 9:35 am Post subject: |
|
|
> 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 |
|
|