# Best practice: CURL or extesion script or other way

**URL:** https://forum.genieacs.com/t/best-practice-curl-or-extesion-script-or-other-way/445
**Category:** Uncategorized
**Created:** [November 12, 2019, 4:34pm UTC](https://forum.genieacs.com/t/best-practice-curl-or-extesion-script-or-other-way/445 "2019-11-12T16:34:22Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![kyob](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.genieacs.com/kyob/32/122_2.png) [@kyob](https://forum.genieacs.com/u/kyob)
#### Post date: [November 12, 2019, 4:34pm UTC](https://forum.genieacs.com/t/best-practice-curl-or-extesion-script-or-other-way/445/1 "2019-11-12T16:34:22Z")

</div>

1. Using curl is the appropriate way to interoperate with GenieACS for ex. client login to WEB PANEL and then click button to change SSID on his router?

2. Or it will be better if I go with ackoder way: [How to pass JSON object to provisioning script](https://forum.genieacs.com/t/how-to-pass-json-object-to-provisioning-script/439/2) (best practice?)

3. Or it depends of my programing skills and purpose?

---

<div class="post-metadata">

### Author: ![akcoder](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.genieacs.com/akcoder/32/11_2.png) [@akcoder](https://forum.genieacs.com/u/akcoder)
#### Post date: [November 12, 2019, 5:52pm UTC](https://forum.genieacs.com/t/best-practice-curl-or-extesion-script-or-other-way/445/2 "2019-11-12T17:52:09Z")

</div>

I wouldn’t use curl, it executes out of process. Use provision scripts and extension scripts.

---

<div class="post-metadata">

### Author: ![kyob](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.genieacs.com/kyob/32/122_2.png) [@kyob](https://forum.genieacs.com/u/kyob)
#### Post date: [November 13, 2019, 11:50am UTC](https://forum.genieacs.com/t/best-practice-curl-or-extesion-script-or-other-way/445/3 "2019-11-13T11:50:07Z")

</div>

Hmm… So how would look equivalent code from CURL to provision scripts and extension scripts.

CURL example:  
[https://github.com/genieacs/genieacs/wiki/API-Reference](https://github.com/genieacs/genieacs/wiki/API-Reference) =\> Change WiFi SSID and password:

```auto
curl -i 'http://localhost:7557/devices/202BC1-BM632w-0000000/tasks?connection_request' \
  -X POST \
  --data '{"name":"setParameterValues", "parameterValues":[["InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.SSID", "GenieACS", "xsd:string"],["InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.PreSharedKey.1.PreSharedKey", "hello world", "xsd:string"]]}'

```

My current logic looks like that:

1. Client log in to WEB PANEL.
2. Client change SSID.
3. After submit SSID change - CURL query is executed.
4. Done! Client router has new SSID.

---

<div class="post-metadata">

### Author: ![akcoder](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.genieacs.com/akcoder/32/11_2.png) [@akcoder](https://forum.genieacs.com/u/akcoder)
#### Post date: [November 13, 2019, 7:48pm UTC](https://forum.genieacs.com/t/best-practice-curl-or-extesion-script-or-other-way/445/4 "2019-11-13T19:48:24Z")

</div>

Okay, now that you have explained things more, using curl from your custom app makes more sense. If you are using PHP, then I would use something like Guzzle to do the HTTP calls instead of shelling out to curl.

One thing to keep in mind is you probably want to do GPVs before the SPVs. If the value you are trying to set is the same as the value in the cached device model, genie won’t set that param on the CPE. Most of the time this won’t be an issue, but sometimes things can get out of sync.

For example, the actual SSID of the CPE might be “Home WiFi”, and for whatever reason the cache value in the data model might be “GenieACS”. If you make the curl call like you have above, then Genie will only actually change the PreSharedKey and not the SSID, and then you will be frustrated as to why the values aren’t changed on the device.

So do this call before the SPV:

```
curl -i 'http://localhost:7557/devices/202BC1-BM632w-0000000/tasks' \
  -X POST \
  --data '{"name":"getParameterValues", "parameterValues":["InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.SSID", "InternetGatewayDevice.LANDevice.1.WLANConfiguration.1.PreSharedKey.1.PreSharedKey"]}'

```

Notice this call does not have ?connection\_request in it. By making this API call first, then doing the SPV call, Genie will batch the requests up, speeding things up.

-dan

---

<div class="post-metadata">

### Author: ![kyob](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.genieacs.com/kyob/32/122_2.png) [@kyob](https://forum.genieacs.com/u/kyob)
#### Post date: [November 14, 2019, 7:19am UTC](https://forum.genieacs.com/t/best-practice-curl-or-extesion-script-or-other-way/445/5 "2019-11-14T07:19:40Z")

</div>

[akcoder](https://forum.genieacs.com/u/akcoder) thank you for your time and hint with Guzzle.
