[OpenSIPS-Users] how to use DB_HTTP module ?

Andrei Dragus adragus at opensips.org
Mon May 17 13:22:17 CEST 2010


Hi,

This module was designed to act as a database module, if you want to use 
it to exchange data with a server you have to work around this.

The "q" variable represents a raw query. Its name cannot be changed, but 
you can give it any value.

You can use the avpops module like this to retrieve data:

avp_db_query("whatever you want to put in the q variable","$avp(i:678)");

The server MUST reply with a HTTP message that has a body similar to:

string
whatever answer you want in the avp

Opensips will take this reply, see that it has only one column and place 
the result in the given avp.

If you want to exchange several variables you have to invent a way to 
put all the variables in a single string.


Andrei.

samoh wrote:
> Hi everyone,
>
> I already posted a message about of how to use db but I did not have
> concrete answers, all those who responded to me told me to see the
> documentation of this module but after reading the documentation several
> time I can't manage to understand how it works, if someone already used the
> module db_http it would very nice of him to show me how he did.
>
> In my opensips.cfg I did this :
>
> modparam("avpops","db_url","http://localhost/db_http")
> modparam("avpops","avp_table","script.php")
>
> I make a query to the http server :
>
> avp_db_query("1");  
> ______________________________________________________________________________________________________
>  if I change "1" by a string I will have it on ::1 - - [17/May/2010:12:31:21
> +0200] "GET /db_http/script.php/?q="string"
> ______________________________________________________________________________________________________
> in the log of apache i have this :
>
> ::1 - - [17/May/2010:12:31:21 +0200] "GET
> /db_http/script.php/?q=1&query_type=custom HTTP/1.1" 200 362 "-" "-"
> 127.0.0.1 - - [17/May/2010:12:31:21 +0200] "POST / HTTP/1.1" 200 45 "-" "-"
>
> My script.php which is in db_http directory on the http server get the
> variable by the url with $_GET['q'] but I don't know how change the name of
> variable "q" AND how send a lot of variable on the http request ???
>
> I would like to send the avp variable to the http sever, after analyzing it
> by my script I wont to retrieve result on my opensips.cfg.
>
> Someone can help me ??
>
> Best regards.
> Sam. 
>
>   

-- 
Andrei Dragus
www.voice-system.ro 




More information about the Users mailing list