[SOLVED] How to call a REST API from the OpenWrt's in-house server?

Dear community,

Hosted on a LAMP server (not my OpenWrt router), I have the shellyclose.php file to close all my shutters at once when hitting that file's url:

function call_REST_API($url){
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, $url);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);

I want to provide a similar service with my OpenWrt router installing as few additional packages as possible due to its tight memory.

Thus my question:

How to consume a REST API method from the default OpenWrt's in-house server?


php exec?...

1 Like

@anon50098793: I want to avoid installing php7 on my router as there is not a lot of space.

Answer to myself:
Creating the file /www/cgi-bin/shellyclose with rights 755 and content:

echo ""
wget -q -O /dev/null --post-data="go=close" http://shutter1/roller/0
wget -q -O /dev/null --post-data="go=close" http://shutter2/roller/0
return 0

...does the trick without installing any additional package.
Just hit url http://openwrt/cgi-bin/shellyclose with the Shelly Button1 to close all the shutters at once.


Nice OOB thinking :sunglasses:

@bluewavenet Thanks :cowboy_hat_face:

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.