Maybe you should make a POST instead of a GET (conventions for
webservice APIs),
_post_data = "action=inc&id=" ^ string_of(port)
response = http.post(data=_post_data, headers=_post_header,
"http://localhost:80/status.php");
I've enclosed the webservice layer library I use and targeted at Shampoo
(it includes the full POST call), adapt it at will.
--
best regards,
okay_awright
<okay_awright AT ddcr DOT biz>
[PGP key on request]
On 09/09/2011 16:26, Guillaume (Numerizik) wrote:
Hello
I want to connect on one page to know how many connect i have to my stream
(with output.harbor)
Here my script. Can you help me ?
def on_connect(~port) =
log("connect to stream...");
http.get("http://localhost80/status.php?id=~port");
end
output.harbor(%mp3(bitrate=128),on_connect=on_connect,port=1234,mount="liste
n",url="http://www.google.com",icy_metadata="true",protocol="icy",source)
http://localhost80/status.php?id=~port record on one database and increase
value. I'll use on_disconnect to limit connection...
what do you think?
thanks
------------------------------------------------------------------------------
Why Cloud-Based Security and Archiving Make Sense
Osterman Research conducted this study that outlines how and why cloud
computing security and archiving is rapidly being adopted across the IT
space for its ease of implementation, lower cost, and increased
reliability. Learn more. http://www.accelacomm.com/jaw/sfnl/114/51425301/
_______________________________________________
Savonet-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/savonet-users
#######################################################################
### Liquidsoap 1.0beta3 multi-part script for Shampoo 0.7alpha1 ###
### Icecast/Shoutcast version ###
### Please share your modifications if you improve upon those files ###
### http://java.net/projects/shampoo/ ###
#######################################################################
# Webservice layer common library
def get_json_list(j) =
error = [("error","1")]
json = of_json(default=error, j)
if json != error then
json
else
[]
end
end
def get_json_map_of_list(j) =
error = [("error",[("error","1")])]
json = of_json(default=error, j)
if json != error then
json
else
[]
end
end
def shampoo_ws_getter(_url) =
log("shampoo_ws_getter()")
response = http.get(_url)
status = snd( fst( fst( fst(response) ) ) )
# TODO: 301 and 307 codes are not handled!
# TODO: make sure content_type is application/json by iterating through
all additional entries in the header
if (status == 200) then
get_json_list(snd(response))
else
[]
end
end
def shampoo_ws_setter(_url, _post_data) =
log("shampoo_ws_setter()")
_post_header = [
("Content-Type", "application/x-www-form-urlencoded")]
response = http.post(data=_post_data, headers=_post_header, _url)
status = snd( fst( fst( fst(response) ) ) )
# TODO: 301 and 307 codes are not handled!
if (status == 200) then
true
else
false
end
end
# Webservice layer public methods
def set_shampoo_channel_onair(_id, _key) =
shampoo_ws_setter(shampoo_ws_host ^ shampoo_ws_setstreameronair_path,
"c=" ^ url.encode(_id) ^ "&k=" ^ url.encode(_key))
end
def set_shampoo_channel_offair(_id, _key) =
shampoo_ws_setter(shampoo_ws_host ^ shampoo_ws_setstreameroffair_path,
"c=" ^ url.encode(_id) ^ "&k=" ^ url.encode(_key))
end
def set_shampoo_live_onair(_id, _key, _timetableslot, _timestamp) =
shampoo_ws_setter(shampoo_ws_host ^ shampoo_ws_setliveonair_path, "c="
^ url.encode(_id) ^ "&k=" ^ url.encode(_key) ^ "&tf=" ^
url.encode(string_of(_timestamp)) ^ "&s=" ^ url.encode(_timetableslot))
end
def set_shampoo_live_offair(_id, _key, _timetableslot, _timestamp) =
shampoo_ws_setter(shampoo_ws_host ^ shampoo_ws_setliveoffair_path, "c="
^ url.encode(_id) ^ "&k=" ^ url.encode(_key) ^ "&tf=" ^
url.encode(string_of(_timestamp)) ^ "&s=" ^ url.encode(_timetableslot))
end
def set_shampoo_item_onair(_id, _key, _item, _timestamp) =
shampoo_ws_setter(shampoo_ws_host ^ shampoo_ws_setitemonair_path, "c="
^ url.encode(_id) ^ "&k=" ^ url.encode(_key) ^ "&tf=" ^
url.encode(string_of(_timestamp)) ^ "&i=" ^ url.encode(_item))
end
def set_shampoo_item_offair(_id, _key, _item, _timestamp) =
shampoo_ws_setter(shampoo_ws_host ^ shampoo_ws_setitemoffair_path, "c="
^ url.encode(_id) ^ "&k=" ^ url.encode(_key) ^ "&tf=" ^
url.encode(string_of(_timestamp)) ^ "&i=" ^ url.encode(_item))
end
def get_shampoo_live(_id, _key, _timestamp) =
shampoo_ws_getter(shampoo_ws_host ^ shampoo_ws_getcurrentlive_path ^
"?c=" ^ url.encode(_id) ^ "&k=" ^ url.encode(_key) ^ "&tf=" ^
url.encode(string_of(_timestamp)))
end
def get_shampoo_nextitem(_id, _key) =
shampoo_ws_getter(shampoo_ws_host ^ shampoo_ws_getnextitem_path ^ "?c="
^ url.encode(_id) ^ "&k=" ^ url.encode(_key))
end
def get_shampoo_channel(_id, _key) =
shampoo_ws_getter(shampoo_ws_host ^ shampoo_ws_getchannel_path ^ "?c="
^ url.encode(_id) ^ "&k=" ^ url.encode(_key))
end
# Unit tests
#print(newline=true, "GET")
#_output = get_shampoo_nextitem("channel1", "0215681688")
#print(newline=true, _output)
#print(newline=true, "POST")
#_output = set_shampoo_channel_onair("channel1", "0215681688")
#print(newline=true, _output)
#print(newline=true, "GET")
#_output = get_shampoo_channel("channel1", "0215681688")
#print(newline=true, _output)
------------------------------------------------------------------------------
Why Cloud-Based Security and Archiving Make Sense
Osterman Research conducted this study that outlines how and why cloud
computing security and archiving is rapidly being adopted across the IT
space for its ease of implementation, lower cost, and increased
reliability. Learn more. http://www.accelacomm.com/jaw/sfnl/114/51425301/
_______________________________________________
Savonet-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/savonet-users