Videoroom REST API call

2,494 views
Skip to first unread message

Mohamed Sadok Ben Jazia

unread,
Sep 7, 2015, 9:45:29 AM9/7/15
to meetecho-janus
Hello,
I want to call videoroom API in a PHP script, i can't find the right parameters to send. I always getting something like this { "janus": "error", "error": { "code": 454, "reason": "JSON error: on line 1: '[' or '{' expected near '-'" } }
I did the same thing (Create, destroy, list) in javascript API and it's working well.
I want an example, or a right request(url and parameters) to use videoroom REST API.
Thx

Lorenzo Miniero

unread,
Sep 7, 2015, 10:10:48 AM9/7/15
to meetecho-janus

Mohamed Sadok Ben Jazia

unread,
Sep 7, 2015, 10:26:21 AM9/7/15
to meetecho-janus
This is a javascript example. I already make it work. I need a server side example

For example i used this url : http://46.16.200.66:8188/janus/
And this Json data 
{
        "janus" : "list",
        "plugin" : "janus.plugin.videoroom",
        "transaction" : "1905767215"
}

I get 0 NO RESPONSE

Lorenzo Miniero

unread,
Sep 7, 2015, 10:28:45 AM9/7/15
to meetecho-janus
There's no difference in talking to Janus from a browser or from a server, the protocol and exchanged messages are the same.
Study the messages that are exchanged in that demo, and more in general the protocol documentation too.


Lorenzo

Mohamed Sadok Ben Jazia

unread,
Sep 7, 2015, 10:34:10 AM9/7/15
to meetecho-janus
It's about integrating janus in a web app, using external database.
Calling Janus from a server is important.

Lorenzo Miniero

unread,
Sep 7, 2015, 6:36:59 PM9/7/15
to meetecho-janus
Yes, I know, and that's what we and other people do :-)
What I mean is you can study the communication that is done in the browser via JavaScript, as the messages you'd send from a server are the same. You create sessions, handles and the like the same way, and the same applies to requests/responses events from plugins.

L.

Mohamed Sadok Ben Jazia

unread,
Sep 9, 2015, 11:59:45 AM9/9/15
to meetecho-janus
I created this code for listing room list..

$data='{"janus":"create","transaction":"zKuHZzgGGuwb"}';
$result=CallAPI('POST',$server,$data);
$instance_id=json_decode($result, true)["data"]["id"];

$data2='{"janus":"attach","plugin":"janus.plugin.videoroom","transaction":"iytlPUfRNS8G"}';
$result=CallAPI('POST',$server2,$data2);
$plugin_id=json_decode($result, true)["data"]["id"];

$data3='{janus: "message", body: {request: "list"}, transaction: "Zc0V36KBCKiV"}';
$result=CallAPI('POST',$server3,$data3);
var_dump(json_decode($result, true));

the two first request works good and return a valid result.
The third one returns   
{ ["janus"]=> string(5) "error" ["error"]=> array(2) { ["code"]=> int(454) ["reason"]=> string(58) "JSON error: on line 1: string or '}' expected near 'janus'" } }
Did i miss something, what solution can be used for this

Lorenzo Miniero

unread,
Sep 10, 2015, 1:50:14 AM9/10/15
to meetecho-janus
In JSON attribute names must we wrapped in quotes.

L.

Mohamed Sadok Ben Jazia

unread,
Dec 14, 2015, 4:08:17 AM12/14/15
to meetecho-janus
Hello,
I reimplemented myself a REST api call using PHP/javascript based on your version of janus.js
You can use securely the admin-api
Feel free to publish on the ressource page.

Lorenzo Miniero

unread,
Dec 14, 2015, 4:40:45 AM12/14/15
to meetecho-janus
Thanks for sharing! I'll update the docs.
This still requires clients to pro-actively refresh sessions, right? IIRC with php you cannt have something lingering in the background that keeps the session state active for you.

L.

Mohamed Sadok Ben Jazia

unread,
Dec 14, 2015, 4:50:17 AM12/14/15
to meetecho-janus
It seems to be working well with the examples.
Anycase, all updates are welcome.
Reply all
Reply to author
Forward
0 new messages